17:48:52,922 WARN [JDBCExceptionReporter] Database selected
17:48:52,938 INFO [STDOUT] Hibernate: select this_.id as id13_0_, this_.office_code as office2_13_0_, this_.name as name13_0_ from seed.nd_office...
17:48:52,953 INFO [STDOUT] Hibernate: insert into seed.nd_registered_trader ...
In the first select, I select an "office" that will be later connected to the main entity, "registered trader". Then,in the application I connect the newly created registered trader to the office and call session.save() for the trader. I select the office trough a Criteria created by the same session, so it's in persistent state. The code looks something like this:
office.getNdRegisteredTrader().add(registeredTrader);
registeredTrader.setOffice(office);
currentSession.save(registeredTrader);
The "select max id" query is not printed, and then I get the following exception:
17:48:53,063 ERROR [JDBCExceptionReporter] ISAM error: duplicate value for a record with unique key.
17:48:53,063 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not insert: [com.itt.ems.seed.dto.nd.NdRegisteredTrader]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2078)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
|