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