-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Bizarre behavior of eclipse/hibernate project
PostPosted: Fri Mar 17, 2017 8:19 am 
Newbie

Joined: Thu Mar 16, 2017 10:42 am
Posts: 7
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.