-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Curious exception...auto-generated id not set?
PostPosted: Tue Oct 21, 2008 11:00 am 
Newbie

Joined: Tue Oct 21, 2008 10:42 am
Posts: 1
Hi all,

i really have a strange behaviour in my EJB-Application:

I've a J2SE-client who connects to a JBoss via JPA with Hibernate and tries to import a lot of entities to a local database.

My entity beans are configured fine as well (the same code on J2SE-Client and JEE-AS).

Im using a J2SE-persistence context which is configured as follows:

Code:
   <persistence-unit name="ClientLocal" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <non-jta-data-source />
      <properties>
       <property name="hibernate.hbm2ddl.auto" value="create" />
         <property name="hibernate.connection.driver_class" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
         <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/dblocal"/>
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
         <property name="hibernate.connection.username" value="***"/>
         <property name="hibernate.connection.password" value="***"/>
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
         
         <property name="jdbc.driver" value="com.mysql.jdbc.Driver"/>
         <property name="jdbc.connection.string"   value="jdbc:mysql://localhost:3306/dblocal"/>
         <property name="jdbc.user" value="***"/>
         <property name="jdbc.password" value="***"/>
         
         <property name="hibernate.hbm2ddl.auto" value="create"/>
         <property name="hibernate.show_sql" value="false"/>
      </properties>   
   </persistence-unit>


All is running really fine, but i get the following exception after commiting on my J2SE-client:

Code:
18618 [main] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 1364, SQLState: HY000
18618 [main] ERROR org.hibernate.util.JDBCExceptionReporter  - Field 'id' doesn't have a default value
18619 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener  - Could not synchronize database state with session


The field "id" is declared as

Code:
   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   public Long id;


and it should be the job of the underlying framework to set this key.

The problem is also solvable by discarding the EntityManagerFactory between the single transactions (what finally causes an OutOfMemory-Exception because it seems to be very memory-intensive).

Any ideas???

Thanks in advance


Daniel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.