File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Unit15-JPA/src/unit15/jpa/Actividad24_Aplicacion Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ package unit15 .jpa .Actividad24_Aplicacion ;
2+
3+ import unit15 .jpa .Actividad22_Aplicacion .Barco ;
4+
5+ import java .util .List ;
6+ import javax .persistence .EntityManager ;
7+ import javax .persistence .EntityManagerFactory ;
8+ import javax .persistence .Persistence ;
9+ import javax .persistence .Query ;
10+
11+
12+ public class Main {
13+
14+
15+ public static void main (String [] args ) {
16+ EntityManagerFactory emf
17+ = Persistence .createEntityManagerFactory ("barcosMarinerosPU" );
18+ EntityManager em = emf .createEntityManager ();
19+
20+ String jpql = "SELECT b FROM Barco b WHERE SIZE(b.marineroCollection) >= 5" ;
21+
22+ Query query = em .createQuery (jpql );
23+ List <Barco > barcos = query .getResultList ();
24+
25+ System .out .println ("Barcos con 3 o más marineros" );
26+ for (Barco b : barcos ) {
27+ System .out .println (b );
28+ }
29+ }
30+ }
31+
You can’t perform that action at this time.
0 commit comments