daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Sep 4th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. EntityManagerFactory emf = Persistence.createEntityManagerFactory("test");      
  2.      EntityManager em =emf.createEntityManager();        
  3.      EntityTransaction tx = em.getTransaction();
  4.      try {
  5.          tx.begin();
  6.           @SuppressWarnings("unchecked")
  7.           List<InputHStock> iph = em.createQuery("from Student").getResultList();
  8.           for (Iterator<InputHStock> iterator = iph.iterator(); iterator.hasNext();) {
  9.             InputHStock student = (InputHStock) iterator.next();
  10.             System.out.println(student.getLocationCode());
  11.           }
  12.           tx.commit();
  13.         } catch (Exception e) {
  14.           tx.rollback();
  15.         }  
  16. }
  17.    
  18. <?xml version="1.0" encoding="UTF-8"?>
  19. <persistence version="2.1"
  20. xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  21. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22.  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
  23.  http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  24.     <persistence-unit name="test">
  25.     <class>application.InputHStock</class>
  26.      <properties>
  27.       <property name="javax.persistence.jdbc.driver"     value="oracle.jdbc.driver.OracleDriver" />
  28.       <property name="javax.persistence.jdbc.url"    value="jdbc:oracle:thin:@localhost:1521:xe" />
  29.       <property name="javax.persistence.jdbc.user" value="testSQL" />
  30.       <property name="javax.persistence.jdbc.password" value="testpwd1" />
  31.       <property name="eclipselink.ddl-generation" value="create-tables" />
  32.       <property name="eclipselink.ddl-generation.output-mode" value="database" />
  33.       </properties>
  34.     </persistence-unit>
  35. </persistence>
  36.    
  37. <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  38.    
  39. <dependency>
  40.             <groupId>org.hibernate</groupId>
  41.             <artifactId>hibernate-entitymanager</artifactId>
  42.         </dependency>
  43.    
  44. <dependency>
  45.     <groupId>org.hibernate</groupId>
  46.     <artifactId>hibernate-entitymanager</artifactId>
  47.     <version>5.3.6.Final</version>
  48. </dependency>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top