List of usage examples for javax.persistence EntityManager close
public void close();
From source file:Professor.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();// www. ja va 2 s . c o m service.findAllProfessors(); util.checkData("select * from Professor"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:Message.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();//from ww w .j a va 2 s . c om service.messageCreateAndList(); util.checkData("select * from Message"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:Professor.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();// w ww .j a v a 2s. com util.checkData("select * from CONTRACT_EMP"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:Professor.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();//from w ww . j a v a 2 s. co m service.lockAllProfessors(); util.checkData("select * from Professor"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:com.doculibre.constellio.services.FacetServicesImpl.java
public static void main(String[] args) { try {/*w ww .ja va2s.c om*/ File solrCoresDir = new File( "C:\\dev\\workspace_searchengine\\.metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps\\constellio\\WEB-INF\\constellio\\collections"); SolrCoreContext.init(); SolrLogContext.init(); RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); FacetServices facetServices = ConstellioSpringUtils.getFacetServices(); RecordCollection webCollection = collectionServices.get("web"); System.out.println(webCollection.getName() + "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"); for (IndexField indexField : webCollection.getIndexFields()) { CollectionFacet facet = new CollectionFacet(); facet.setFacetType(CollectionFacet.FIELD_FACET); facet.setRecordCollection(webCollection); facet.setFacetField(indexField); System.out.println("Field : " + indexField.getName()); System.out.println(" Toutes les valeurs : "); List<String> values = facetServices.getValues(facet); for (String value : values) { System.out.println(" - " + value); } System.out.println(" Suggestions : "); List<String> suggestions = facetServices.suggestValues(facet, "bonjour"); for (String value : suggestions) { System.out.println(" - " + value); } } EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager(); entityManager.close(); SolrCoreContext.shutdown(); } catch (Exception e) { e.printStackTrace(); } finally { System.exit(0); } }
From source file:Main.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();/*from w w w .j a v a 2 s. c o m*/ service.findAll(); util.checkData("select * from Professor"); util.checkData("select * from Department"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:Professor.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();//from w w w . ja va 2 s. c o m Professor emp = service.createProfessor("AAA", 45000); em.getTransaction().commit(); System.out.println("Persisted " + emp); util.checkData("select * from Professor"); em.close(); emf.close(); }
From source file:Department.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();/*w w w.jav a 2s .c om*/ service.createProfessor(1, "empName", 1); util.checkData("select * from Professor"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:Professor.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();// w ww.j a v a 2 s .c om //service.removeDepartment2(); util.checkData("select * from Professor"); util.checkData("select * from Department"); em.getTransaction().commit(); em.close(); emf.close(); }
From source file:Professor.java
public static void main(String[] a) throws Exception { JPAUtil util = new JPAUtil(); util.executeSQLCommand("CREATE SEQUENCE Emp_Seq;"); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService"); EntityManager em = emf.createEntityManager(); ProfessorService service = new ProfessorService(em); em.getTransaction().begin();/*from ww w . j a v a2s . c om*/ Professor emp = service.createProfessor("name", 100); em.getTransaction().commit(); System.out.println("Persisted " + emp); util.checkData("select * from Professor"); em.close(); emf.close(); }