Hello,

I created a small test project with an embedded HSQLDB.

Everything works fine, but I can not persist data. I don't get an exception but 
after making a commit no data is present in my table.

Here are some fragments of my source code:


  | ?xml version="1.0" encoding="UTF-8"?>
  | <persistence xmlns="http://java.sun.com/xml/ns/persistence";>
  |     <persistence-unit name="cust" transaction-type="RESOURCE_LOCAL">
  |         <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |         <class>com.kontron.entity.Customer</class> 
  |         <class>com.kontron.entity.Country</class> 
  |         <properties>
  |             <property name="hibernate.connection.driver_class" 
value="org.hsqldb.jdbcDriver"/>
  |             <property name="hibernate.connection.url" 
value="jdbc:hsqldb:data/localDB"/>
  |             <property name="hibernate.dialect" 
value="org.hibernate.dialect.HSQLDialect"/>
  |             <property name="hibernate.connection.username" value="sa"/>
  |             <property name="hibernate.connection.password" value=""/>
  |             <property name="hibernate.max_fetch_depth" value="3"/>
  |             <property name="hibernate.show_sql" value="true"/>
  |             <property name="hibernate.hbm2ddl.auto" value="none" /> 
  |         </properties>
  |     </persistence-unit>
  | </persistence>
  | 

Here is my java code:


  | EntityManagerFactory emf = Persistence.createEntityManagerFactory("cust");
  |             EntityManager em = emf.createEntityManager();
  | 
  |             
  |             CustomerService src = new CustomerService();
  |             src.setEntityManager(em);
  |             
  |             em.getTransaction().begin();
  |             
  | 
  |             Customer cust = new Customer();
  |             cust.setId(2);
  |             cust.setName("Hallo AG");
  |             src.persistCustomer(cust);
  |     
  |             em.getTransaction().commit();
  |             
  |             em.close();
  |             emf.close();

What am I doing wrong?

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3951951#3951951

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3951951


_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to