Hello,
When I run my many-to-many hibernate project in eclipse, if the eclipse workbench is freshly restarted, the HQL's are shown fully trying to insert into child tables too and then throws exception, like this:
Code:
Hibernate:
/* insert net.viralpatel.hibernate.Employee
*/ insert
into
EMPLOYEE
(FIRSTNAME, LASTNAME, EMPLOYEEID)
values
(?, ?, ?)
Hibernate:
/* insert net.viralpatel.hibernate.Employee
*/ insert
into
EMPLOYEE
(FIRSTNAME, LASTNAME, EMPLOYEEID)
values
(?, ?, ?)
Hibernate:
/* create one-to-many row net.viralpatel.hibernate.Employee.meetings */ update
MEETING
set
EMPLOYEEID=?
where
MEETINGID=?
Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: net.viralpatel.hibernate.Meeting
at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:294)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:537)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:165)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:899)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1308)
at org.hibernate.persister.collection.OneToManyPersister.recreate(OneToManyPersister.java:184)
at org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:67)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at net.viralpatel.hibernate.Main.main(Main.java:39)
But when I try running the same application any number of consequetive times, the HQL stops midway (as if hung or stuck somewhere), and does not show the child table insert statement. (No data is inserted into database in either case). The console looks like this:
Code:
Hibernate:
/* insert net.viralpatel.hibernate.Employee
*/ insert
into
EMPLOYEE
(FIRSTNAME, LASTNAME, EMPLOYEEID)
values
(?, ?, ?)
What is the reason for the above behavior? I tried increasing memory for the application within eclipse but doesn't work.
Thanks.