This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Regarding Entirty relationships..." Watch "Regarding Entirty relationships..." New topic

Regarding Entirty relationships...

Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 98
Hi I am new to EJB 3.0
While working with Entity relationships i am getting the fallwoing error...
I have created a
class and a
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(
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.jdbc.AbstractBatcher.executeBatch(
at org.hibernate.engine.ActionQueue.executeActions(
at org.hibernate.engine.ActionQueue.executeActions(
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
at org.hibernate.impl.SessionImpl.flush(
at org.hibernate.impl.SessionImpl.managedFlush(
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(
... 29 more
Caused by: java.sql.BatchUpdateException: failed batch
Bala Gangadhar
Ranch Hand

Joined: Oct 07, 2008
Posts: 98
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: 98
Thanks for the reply.... I got it now...thanks a alot...
It is sorta covered in the JavaRanch Style Guide.
subject: Regarding Entirty relationships...
jQuery in Action, 3rd edition