aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Regarding Entirty relationships... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Regarding Entirty relationships..." Watch "Regarding Entirty relationships..." New topic
Author

Regarding Entirty relationships...

Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
Hi I am new to EJB 3.0
While working with Entity relationships i am getting the fallwoing error...
I have created a
customer
class and a
Address
calss and add one to one unidirectional relationship as fallwos...



and Address class as...


And I am using the TravelAgent session bean to maintain the entities...

And the client code is as



And the problem is when i execute the client program for the first time it is adding the customer and address entities in the db successfully but for the second time i am getting an error. I could add another entity only after restarting the server....please let me know where i went wrong....
The error is...
Caused by: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
... 29 more
Caused by: java.sql.BatchUpdateException: failed batch
Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
Any one please reply....or let me know if you need more information.....
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
It fails to update/insert the values to the database, i would suggest double checking if there are some missing constraints. get the generated SQL commands and try executing them using a DB client. in addition SQL exceptions are wrapped inside another exception so I would suggest to get the original cause of the exception, which will explain the cause.


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 82
    
    1
Thanks for the reply.... I got it now...thanks a alot...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Entirty relationships...