-->
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.  [ 5 posts ] 
Author Message
 Post subject: Assertion failed in Hibernate
PostPosted: Fri Dec 05, 2003 7:32 am 
Newbie

Joined: Wed Aug 27, 2003 2:23 am
Posts: 5
Location: Lahore, Pakistan
I upgraded to 2.1rc1 and ended up getting the following error:

Code:
     [java] ERROR [PoolThread-0] (AssertionFailure.java:20) - An AssertionFailure occured - this may indicate a bug in Hibernate
     [java] net.sf.hibernate.AssertionFailure: null identifier
     [java]     at net.sf.hibernate.engine.Key.<init>(Key.java:22)
     [java]     at net.sf.hibernate.engine.Key.<init>(Key.java:32)
     [java]     at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1371)
     [java]     at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1398)
     [java]     at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1322)
     [java]     at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
     [java]     at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
     [java]     at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
     [java]     at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
     [java]     at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
     [java]     at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:890)
     [java]     at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:815)
     [java]     at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:738)
     [java]     at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:715)



My application creates an instance of class RFQ, adds elements to the RFQSupplier and RFQRequisitionItem bags and calls session.save(newRFO). Hibernate 2.1beta6 would persist the object and its collections; 2.1rc1 generates the exception. I used hbm2java to generate the class files. I made no change to the generated java code; the hashCode and equals methods are the ones autogenerated by hbm2java.

I am using java 1.4.2_02-b03, cglib2 and all the .jar files in hibernate-2.1/lib.

Here are the hbm files:

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 schema="CPO2">
<class name="com.cgc.esd.pages.cinv.RFQ" table="CPO_RFQ">

   <id name="id" column="RFQ_ID" type="java.lang.Long" unsaved-value="null">
             <generator class="native">
               <param name ="sequence">CPO_RFQ_S</param>
             </generator>
   </id>

      <timestamp  name="lastUpdate" column="LAST_UPDATE_DATE"></timestamp>

        <property name="inventoryClass" column="INV_CLASS" type="string"/>
        <property name="rfqTypeLookup" column="RFQ_TYPE_LKP" type="string"/>
        <property name="itemClass" column="ITEM_CLASS" type="string"/>
        <property name="rfqCreationDate" column="RFQ_CREATION_DATE" type="timestamp"/>
        <property name="shipToLookup" column="SHIP_TO_LKP" type="string"/>
        <property name="billToLookup" column="BILL_TO_LKP" type="string"/>
        <property name="statusLookup" column="RFQ_STATUS_LKP" type="string"/>
        <property name="shipViaLookup" column="SHIP_VIA_LKP" type="string"/>
        <property name="replyViaLookup" column="REPLY_VIA_LKP" type="string"/>
        <property name="shipmentTermsLookup" column="SHIPMENT_TERMS_LKP" type="string"/>
        <property name="dueDate" column="DUE_DATE" type="timestamp"/>
        <property name="isFreightIncluded" column="IS_FREIGHT_INCLUDED" type="string"/>
        <property name="remarks" column="REMARKS" type="string"/>
        <property name="actorId" column="ACTOR_ID" type="java.lang.Long"/>
        <property name="userId" column="USER_ID" type="java.lang.Long"/>

        <property name="createByUserId" column="CREATED_BY" type="java.lang.Long"/>
        <property name="creationDate" column="CREATION_DATE" type="timestamp"/>
        <property name="lastUpdatedByUserId" column="LAST_UPDATED_BY" type="java.lang.Long"/>

        <bag name="rfqRequisitionItems" table="CPO_RFQ_REQN_ITEMS"
              lazy="true" cascade="save-update" inverse="true">
          <key column="RFQ_ID"/>
     <one-to-many class="com.cgc.esd.pages.cinv.RFQRequisitionItem"/>
        </bag>

        <bag name="rfqSuppliers" table="CPO_RFQ_SUPPLIERS"
              lazy="true" cascade="save-update" inverse="true">
          <key column="RFQ_ID"/>
     <one-to-many class="com.cgc.esd.pages.cinv.RFQSupplier"/>
        </bag>

</class>

</hibernate-mapping>





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 schema="CPO2">
<class name="com.cgc.esd.pages.cinv.RFQRequisitionItem" table="CPO_RFQ_REQN_ITEMS">

   <id name="id" column="RFQ_REQN_ITEM_ID" type="java.lang.Long" unsaved-value="null">
             <generator class="native">
               <param name ="sequence">CPO_RFQ_REQN_ITEMS_S</param>
             </generator>
   </id>

        <timestamp  name="lastUpdate" column="LAST_UPDATE_DATE"></timestamp>

        <property name="weight"       column="WGT" type="java.lang.Long"/>
        <property name="isWithSample" column="IS_WITH_SAMPLE" type="string"/>
        <property name="packingInformation" column="PACKING_INFO" type="string"/>
        <property name="resourcesRequired" column="RESOURCES_REQD" type="java.lang.Long"/>
        <property name="remarks" column="REMARKS" type="string"/>

        <property name="createByUserId" column="CREATED_BY" type="java.lang.Long"/>
        <property name="creationDate" column="CREATION_DATE" type="timestamp"/>
        <property name="lastUpdatedByUserId" column="LAST_UPDATED_BY" type="java.lang.Long"/>

        <!-- many to one with RFQ -->
        <many-to-one name="rfq"
               class="com.cgc.esd.pages.cinv.RFQ"
               column="RFQ_ID" not-null="true"/>

        <!-- many to one with requisitionItem -->
        <many-to-one name="requisitionItem"
               class="com.cgc.esd.pages.cinv.RequisitionItem"
               column="REQN_ITEM_ID"/>

</class>

</hibernate-mapping>





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 schema="CPO2">
<class name="com.cgc.esd.pages.cinv.RFQSupplier" table="CPO_RFQ_SUPPLIERS">

   <id name="id" column="RFQ_SUPL_ID" type="java.lang.Long" unsaved-value="null">
          <generator class="native">
            <param name ="sequence">CPO_RFQ_SUPPLIERS_S</param>
          </generator>
   </id>

        <timestamp  name="lastUpdate" column="LAST_UPDATE_DATE"></timestamp>

        <property name="createByUserId" column="CREATED_BY" type="java.lang.Long"/>
        <property name="creationDate" column="CREATION_DATE" type="timestamp"/>
        <property name="lastUpdatedByUserId" column="LAST_UPDATED_BY" type="java.lang.Long"/>

        <!-- many to one with RFQ -->
        <many-to-one name="parentRfq"
               class="com.cgc.esd.pages.cinv.RFQ"
               column="RFQ_ID" not-null="true"/>

        <!-- many to one with Supplier -->
        <many-to-one name="supplier"
               class="com.cgc.esd.pages.cinv.Supplier"
               column="SUPL_ID" cascade="none" />

</class>

</hibernate-mapping>




Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 7:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Apparently your timestamps are non-null, so 2.1rc1 thinks that the objects are detached. I will make a little change to tolerate this, but why on earth are you setting the timestamp property of a newly instantiated object?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 3:31 pm 
Newbie

Joined: Wed Aug 27, 2003 2:23 am
Posts: 5
Location: Lahore, Pakistan
Yes, the timestamp is not null. I assign the value returned by java.util.Date() to the timestamp property of the object.

The underlying Oracle db tables belong to Oracle Financials applications which set the CREATE_DATE and LAST_UPDATE_DATE columns whenever a new tuple is added or an existing tuple is modified. My application is web-based. I have to set the CREATE_DATE and LAST_UPDATE_DATE columns when I persist newly created objects; I do this by assigning Date() values to the appropriate properties of the newly created objects being persisted. My reasoning was that while I have loaded an object from the oracle tables, some Oracle Financial application might update the tuple underneath. This is will be signified by a change in the LAST_UPDATE_DATE value. My understanding of <timestamp> is that it would allow me detect such a circumstance. I may have gotten it wrong; if there is a better strategy to tackle this, please recommend.

Sohail Aslam
techlogix.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 9:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is no point in ever assigning a valut to a <timestamp> property because Hibernate regenerates the value every time the object is persisted.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 5:43 am 
Newbie

Joined: Wed Aug 27, 2003 2:23 am
Posts: 5
Location: Lahore, Pakistan
Thanks for the clarification. I will make the change in my code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.