#19 hibernate assigned keys and relations

closed
nobody
None
5
2006-04-30
2005-07-10
No

In a case a new record is created with hibernate (2 and
3) and an assigned primary key (not autogenerated) is
used in combination with a relation, the following error
occurs:

Caused by:
net.sf.hibernate.exception.ConstraintViolationException:
Could not execute JDBC batch update
at
net.sf.hibernate.exception.ErrorCodeConverter.convert
(ErrorCodeConverter.java:73)
at
net.sf.hibernate.exception.JDBCExceptionHelper.convert
(JDBCExceptionHelper.java:30)
at net.sf.hibernate.impl.BatcherImpl.convert
(BatcherImpl.java:325)
at
net.sf.hibernate.impl.BatcherImpl.executeBatch
(BatcherImpl.java:134)
at
net.sf.hibernate.impl.SessionImpl.executeAll
(SessionImpl.java:2441)
at net.sf.hibernate.impl.SessionImpl.execute
(SessionImpl.java:2391)
at net.sf.hibernate.impl.SessionImpl.flush
(SessionImpl.java:2260)
at
net.sf.hibernate.transaction.JDBCTransaction.commit
(JDBCTransaction.java:61)
at
com.finalist.session.UserManagerFacade.addTAdress
(UserManagerFacade.java:74)
... 47 more
Caused by: java.sql.BatchUpdateException: Cannot add
or update a child row: a foreign key constraint fails
at
com.mysql.jdbc.ServerPreparedStatement.executeBatch
(ServerPreparedStatement.java:827)
at
com.mchange.v2.sql.filter.FilterPreparedStatement.exec
uteBatch(FilterPreparedStatement.java:260)
at
net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch
(BatchingBatcher.java:54)
at
net.sf.hibernate.impl.BatcherImpl.executeBatch
(BatcherImpl.java:127)
... 52 more

Discussion

  • Rudie Ekkelenkamp

    Logged In: YES
    user_id=830344

    Looks like a hibernate bug too me. You can not have ID's
    on primary keys that are relations.

     
  • Rudie Ekkelenkamp

    • status: open --> closed
     

Log in to post a comment.