List of usage examples for javax.persistence EntityManager createQuery
public Query createQuery(CriteriaDelete deleteQuery);
Query
for executing a criteria delete query. From source file:streaming.StreamingTest.java
public void filmFantastiqueOrdreAlpha() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<Film> films = em .createQuery(/* w ww. jav a2s . c o m*/ "SELECT f FROM Film f JOIN f.genre g WHERE g.nom = 'Fantastique' ORDER BY f.titre ASC") .getResultList(); for (Film f : films) { System.out.println(f.getTitre()); } }
From source file:streaming.StreamingTest.java
public void trierParOrdreChronologique() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); Collection<Film> film = em.createQuery("SELECT f FROM Film f ORDER BY f.annee").getResultList(); for (Film f : film) { System.out.println(f.getTitre()); }/*from w w w . j av a 2 s . c o m*/ }
From source file:streaming.StreamingTest.java
public void filmsParFreresCoen() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<Film> filmsCoen = em.createQuery( "SELECT f FROM Film f JOIN f.listeRealisateurs r WHERE r.prenom = 'Ethan' INTERSECT SELECT f FROM Film f JOIN f.listeRealisateurs r WHERE r.prenom = 'Joel'") .getResultList();/*from w ww . j a v a 2 s . co m*/ for (Film f : filmsCoen) { System.out.println(f.getTitre()); } }
From source file:streaming.StreamingTest.java
public void filmsParFreresCoen2() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<Film> filmsCoen = em.createQuery( "SELECT f FROM Film f WHERE f.id IN (SELECT f.id FROM Film f JOIN f.listeRealisateurs r WHERE r.prenom = 'Ethan') AND f.id IN (SELECT f.id FROM Film f JOIN f.listeRealisateurs r WHERE r.prenom = 'Joel') ") .getResultList();// w ww .ja va 2 s . c om for (Film f : filmsCoen) { System.out.println(f.getTitre()); } }
From source file:streaming.StreamingTest.java
public void filmsActionFrereCoenParAnneeProd() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<Film> filmsAction = em.createQuery( "SELECT f FROM Film f JOIN f.listeRealisateurs r JOIN f.genre g WHERE (g.nom = 'Comdie') and (r.prenom = 'Ethan') ORDER BY f.annee ASC") .getResultList();//from www. j a v a 2s . co m for (Film f : filmsAction) { System.out.println(f.getTitre()); } }
From source file:streaming.StreamingTest.java
public void filmPlusAncienJackson() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<String> filmAncien = em.createQuery( "SELECT f.titre FROM Film f WHERE f.annee IN (SELECT MIN(f.annee) FROM Film f JOIN f.listeRealisateurs r WHERE r.nom = 'JACKSON') ") .getResultList();/*from w w w . j av a 2 s . c om*/ for (String titre : filmAncien) { System.out.println(titre); } }
From source file:streaming.StreamingTest.java
public void filmsAutresQueAction() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<Film> filmsPasAction = em.createQuery("SELECT f FROM Film f JOIN f.genre g WHERE g.nom <> 'Action'") .getResultList();//from w w w.j a va 2 s. c o m for (Film f : filmsPasAction) { System.out.println(f.getTitre()); } }
From source file:streaming.StreamingTest.java
public void filmsNeoZelandaisSaufFantastique() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); List<Film> filmsPasAction = em.createQuery( "SELECT f FROM Film f JOIN f.genre g JOIN f.pays p WHERE g.nom <> 'Fantastique' AND p.nom = 'Nouvelle-Zlande'") .getResultList();//from ww w .j av a 2 s . c o m System.out.println(filmsPasAction.size()); }
From source file:streaming.StreamingTest.java
public void moyenneAnneeProd() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); Double moyenneAnnee = (Double) em.createQuery("SELECT AVG(f.annee) FROM Film f").getSingleResult(); System.out.println(moyenneAnnee); }
From source file:streaming.StreamingTest.java
public void filmsFantastique() { EntityManager em = Persistence.createEntityManagerFactory("StreamingPU").createEntityManager(); Long filmsFantastique = (Long) em .createQuery("SELECT COUNT (f) FROM Film f JOIN f.genre g WHERE g.nom = 'Fantastique'") .getSingleResult();/*w w w . jav a2s .c o m*/ System.out.println(filmsFantastique); }