-->
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: AssertionFailure on session flush
PostPosted: Fri May 07, 2004 6:19 am 
Newbie

Joined: Wed Sep 10, 2003 1:21 pm
Posts: 6
Hi,

I am regularly experiencing the following bug:

Code:
[net.sf.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
net.sf.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
        at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2630)
        at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2454)
        at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2447)
        at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2249)
        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228)
        at za.co.quirk.milk.action.dairy.DairyImportAction.execute(DairyImportAction.java:101)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
....


My Hibernate version is 2.1.3. The database is MySQL 4.0.18. Here is an excerpt from the mapping file:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class name="za.co.quirk.milk.model.Contact" table="contact">
        <id name="id">
           <generator class="native"/>
        </id>
        ....

    </class>
   
</hibernate-mapping>


The code excerpt:

Code:
    for( int row = 2; ( line = parser.getNextLine() ) != null; row++ )
    { 
.....

      Contact contact = (Contact)addressMap.get( email );
      if( contact == null )
      {
        contact = new Contact();
      }
     
.....

      session.saveOrUpdate( contact );
      if( row % 256 == 0 )
      {
        session.flush();
      }
    }


The flush every 256 rows is done to avoid the session becoming too "loaded" with unsaved objects, as the number of rows can be large. Is this "unsafe use of the session" as suggested in the exception?

Thanks,
Craig


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.