-->
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: Error when saving one-to-many relationship
PostPosted: Fri Aug 20, 2004 3:22 pm 
Newbie

Joined: Fri Aug 13, 2004 12:17 pm
Posts: 12
Location: St. Louis, MO
Hibernate version: 2.1.6

Mapping documents:
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="gov.usps.sakcarrier.db.vo.PSF2734RootRecord"
        table="PSF2734_ROOT"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="ROOT_ID"
            type="int"
            unsaved-value="-1"
        >
            <generator class="sequence">
                <param name="sequence">PSF2734ROOT_ID_SEQ</param>
            </generator>
        </id>

        <property
            name="dateEntered"
            type="date"
            update="true"
            insert="true"
            access="property"
            column="DATE_ENTERED"
            not-null="true"
            unique="false"
        />

        <property
            name="dateScheduled"
            type="date"
            update="true"
            insert="true"
            access="property"
            column="DATE_SCHEDULED"
            not-null="true"
            unique="false"
        />

        <many-to-one
            name="deductApprover"
            class="gov.usps.sakcarrier.db.vo.CarrierUser"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="DEDUCT_CARRIER_USER_ID"
        />

        <many-to-one
            name="deductCarrier"
            class="gov.usps.sakcarrier.db.vo.Carrier"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="DEDUCT_CARRIER_ID"
        />

        <many-to-one
            name="gainCarrier"
            class="gov.usps.sakcarrier.db.vo.Carrier"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="GAIN_CARRIER_ID"
        />

        <many-to-one
            name="gainApprover"
            class="gov.usps.sakcarrier.db.vo.CarrierUser"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="GAIN_CARRIER_USER_ID"
        />

        <many-to-one
            name="origin"
            class="gov.usps.sakcarrier.db.vo.AirStop"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="ORIGIN_ID"
        />

        <property
            name="repossessionFlag"
            type="boolean"
            update="true"
            insert="true"
            access="property"
            column="REPOSSESSION_FLAG"
            not-null="true"
            unique="false"
        />

        <property
            name="serialNumber"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="SERIAL_NUMBER"
            length="9"
            not-null="true"
            unique="true"
        />

        <property
            name="updateDate"
            type="date"
            update="true"
            insert="true"
            access="property"
            column="LAST_UPDT_DTM"
            not-null="true"
            unique="false"
        />

        <property
            name="updateUser"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="UPDT_USER_ID"
            length="32"
            not-null="true"
            unique="false"
        />

        <set
            name="details"
            lazy="true"
            inverse="true"
            cascade="all-delete-orphan"
            sort="unsorted"
        >

              <key
                  column="PSF2734ROOT_ID"
              >
              </key>

              <one-to-many
                  class="gov.usps.sakcarrier.db.vo.PSF2734DetailRecord"
              />
        </set>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-PSF2734RootRecord.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>

Code:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="gov.usps.sakcarrier.db.vo.PSF2734DetailRecord"
        table="PSF2734_DETAILS"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="DETAIL_ID"
            type="int"
            unsaved-value="-1"
        >
            <generator class="sequence">
                <param name="sequence">PSF2734DETAIL_ID_SEQ</param>
            </generator>
        </id>

        <property
            name="deductCarrierTailNumber"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="DEDUCT_TAIL_NUM"
            length="20"
            not-null="false"
            unique="false"
        />

        <many-to-one
            name="destination"
            class="gov.usps.sakcarrier.db.vo.AirStop"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="DESTINATION_ID"
        />

        <property
            name="gainCarrierTailNumber"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="GAIN_TAIL_NUM"
            length="20"
            not-null="false"
            unique="false"
        />

        <property
            name="nonPriorityWeight"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="NON_PRI_WEIGHT"
            not-null="false"
            unique="false"
        />

        <property
            name="priorityWeight"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="PRI_WEIGHT"
            not-null="false"
            unique="false"
        />

        <property
            name="sequenceNumber"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="SEQUENCE_NUM"
            not-null="true"
            unique="false"
        />

        <many-to-one
            name="parent"
            class="gov.usps.sakcarrier.db.vo.PSF2734RootRecord"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="PSF2734ROOT_ID"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-PSF2734DetailRecord.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
using spring...
Code:
public Integer savePSF2734(PSF2734RootRecord r) {
      return (Integer) getHibernateTemplate().save(r);
   }


essentially session.save()


Name and version of the database you are using: Oracle 9i

Debug level Hibernate log excerpt:
Code:
[2004-08-20 14:02:59,081] DEBUG (net.sf.hibernate.impl.SessionImpl <init>.555)  - opened session
[2004-08-20 14:02:59,081] DEBUG (net.sf.hibernate.impl.BatcherImpl logOpenPreparedStatement.200)  - about to open: 0 open PreparedStatements, 0 open ResultSets
[2004-08-20 14:02:59,144] DEBUG (net.sf.hibernate.SQL log.226)  - select PSF2734ROOT_ID_SEQ.nextval from dual
Hibernate: select PSF2734ROOT_ID_SEQ.nextval from dual
[2004-08-20 14:02:59,144] DEBUG (net.sf.hibernate.impl.BatcherImpl getPreparedStatement.249)  - preparing statement
[2004-08-20 14:02:59,597] DEBUG (net.sf.hibernate.id.SequenceGenerator generate.81)  - Sequence identifier generated: 16
[2004-08-20 14:02:59,597] DEBUG (net.sf.hibernate.impl.BatcherImpl logClosePreparedStatement.207)  - done closing: 0 open PreparedStatements, 0 open ResultSets
[2004-08-20 14:02:59,597] DEBUG (net.sf.hibernate.impl.BatcherImpl closePreparedStatement.269)  - closing statement
[2004-08-20 14:02:59,660] DEBUG (net.sf.hibernate.impl.SessionImpl saveWithGeneratedIdentifier.778)  - generated identifier: 16
[2004-08-20 14:02:59,660] DEBUG (net.sf.hibernate.impl.SessionImpl doSave.825)  - saving [gov.usps.sakcarrier.db.vo.PSF2734RootRecord#16]
[2004-08-20 14:02:59,675] DEBUG (net.sf.hibernate.engine.Cascades cascade.497)  - processing cascades for: gov.usps.sakcarrier.db.vo.PSF2734RootRecord
[2004-08-20 14:02:59,675] DEBUG (net.sf.hibernate.engine.Cascades cascade.506)  - done processing cascades for: gov.usps.sakcarrier.db.vo.PSF2734RootRecord


When I attempt to save the parent in this one-to-many relationship, my application/unit test terminates with no exception. The bottom of the above excerpt is the last thing that is printed out. I am setting parent.setChildren(Set s) and child.setParent(). Depending on how I have the cascade set, it will either stop now, or it will complete the insert into database correctly, then terminate with no exception. If there are any other files/excerpts I should post, please let me know.

R


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 3:51 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
commit?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 4:14 pm 
Newbie

Joined: Fri Aug 13, 2004 12:17 pm
Posts: 12
Location: St. Louis, MO
Well show sql is on, and I don't even see the insert statements. There should also be two selects to pull the id numbers down for both tables. It seems to be seizing up before it gets to that point. Additionally, there can be operations in the unit test or test application (tried both) and the thread just terminates, it never reaches them, even if they're placed in a finally block.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 4:49 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
it never reaches them, even if they're placed in a finally block.


very strange behaviour, try forcing flush() just after .save, then debug and see where the thread is going.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.