-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Assertion Failure
PostPosted: Tue Mar 10, 2009 9:04 am 
Newbie

Joined: Tue Mar 10, 2009 8:49 am
Posts: 3
Hi,

i have a problem with hibernate...
A Child can't be saved, because the hibernate have an error. How know what i do false.....

The Source and the Error you see in the next few lines.....

THANKS FOR EACH ANSWER



Hibernate version:
hibernate3.jar


Logfile documents:

44500 [RMI TCP Connection(6)-192.168.101.87] ERROR 2009-03-10 09:29:48,656 org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in knxathome.persistence.pojos.NavigationElement entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:978)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:135)
at org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:60)
at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1245)
at knxservice.persistence.logic.NestedSet.getTree(NestedSet.java:346)
at knxathome.persistence.rmi.RmiPersisterImpl.getTree(RmiPersisterImpl.java:312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
44531 [RMI TCP Connection(6)-192.168.101.87] INFO 2009-03-10 09:29:48,687 knxservice.persistence.logic.VisualizationLogic - Getting parent element id for primary key: 1

Quelltext:

.....
// finally append the new child
child.setLft(parent.getLft() + (offset - 1));
child.setRgt(parent.getLft() + offset);
primaryKey = (Integer) session.save(child);//<<< error line...

// commit transaction
tx.commit();
....





Problems with Session and transaction handling?

Read this: http://hibernate.org/42.htm


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 3:38 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
As the assertion message says:
Quote:
don't flush the Session after an exception occurs

Are you doing the tx.commit(); even after an exception.

Is this code in the finally block?
Quote:
// finally append the new child
child.setLft(parent.getLft() + (offset - 1));
child.setRgt(parent.getLft() + offset);
primaryKey = (Integer) session.save(child);//<<< error line...

// commit transaction
tx.commit();

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 4:45 am 
Newbie

Joined: Tue Mar 10, 2009 8:49 am
Posts: 3
this code is in the finally block and at the end i commit the transaction.

My Problem is this line, which i marked with "error line". If i delete this line, the programm won't be have an error.....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 4:51 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Well if the code is in the finally block then it answers why you are getting this assertion. In the try block there was some exception which occurred which makes hibernate session flawed, but in the finally block you are trying to flush this flawed session. And that's why you are getting the assertion.

Why are you saving the child in the finally block?

_________________
Regards,
Litty Preeth


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

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.