Hi,
We are experiencing odd behaviour that we cannot explain. We load an an object RenewalAccount which has a reference to a Contact which in turn has a reference to Address.
The initial load seems to work, and all the object references are populated. However, at the end of this same initial load an update is made to the bottomost Address object which nullifies all the columns except the first column, which has the previous column 6 data bound into it!
We have proven this with Hibernate's debugging information which we include some of at the bottom of this post; specifically the hydration and dehydration of Address.
Your insight into this matter very much appreciated!
Hibernate version:
2.1
Mapping documents:
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="dbOnlineRenewals.dbo">
<class name="com.qas.newmedia.internet.renewals.dto.RenewalAccount"
table="tblRenewalAccounts">
<id name="id" type="int" column="renewal_account_id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="accountRef" column="account_ref" not-null="true" />
<property name="status" column="status" not-null="true" />
<property name="rnfReturned" column="rnf_returned" not-null="false" />
<property name="currencyCode" column="currency_code" not-null="false" />
<property name="correspondanceType" column="correspondance_type" not-null="false" />
<many-to-one name="parentAccountContact" class="com.qas.newmedia.internet.renewals.dto.EmployeeContact" column="parent_account_contact_id" />
<many-to-one name="renewalContact" class="com.qas.newmedia.internet.renewals.dto.EmployeeContact" column="renewal_contact_id" />
<many-to-one name="updatedRenewalContact" class="com.qas.newmedia.internet.renewals.dto.EmployeeContact" column="updated_renewal_contact_id" />
<property name="dateContactLeft" column="date_contact_left" not-null="false" type="java.util.Calendar" />
<set name="renewalItems" inverse="true" cascade="all" lazy="true" order-by="product_name">
<key column="renewal_account_id"/>
<one-to-many class="com.qas.newmedia.internet.renewals.dto.RenewalItem"/>
</set>
<property name="userActionStatus" column="user_action_status" not-null="false" />
<many-to-one name="paymentMethod" class="com.qas.newmedia.internet.renewals.dto.Payment" column="payment_id" />
<property name="loginId">
<column name="login_id" not-null="true" sql-type="uniqueidentifier" />
</property>
<property name="dateFirstLoggedIn" column="date_first_logged_in" not-null="false" type="java.util.Calendar" />
<property name="dateLastLoggedIn" column="date_last_logged_in" not-null="false" type="java.util.Calendar" />
<property name="loginCount" column="login_count" not-null="false" />
</class>
<class name="com.qas.newmedia.internet.renewals.dto.RenewalItem"
table="tblRenewalItems">
<id name="id" type="int" column="renewal_item_id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="month" column="month" not-null="true" />
<property name="year" column="year" not-null="true" />
<property name="productName" column="product_name" not-null="true" />
<property name="productFamily" column="product_family" not-null="true" />
<property name="operatingSystem" column="operating_system" not-null="false" />
<property name="release" column="release" not-null="true" />
<property name="quantity" column="quantity" not-null="true" />
<property name="initialDiscountedPrice">
<column name="initial_discounted_price" not-null="true" sql-type="money" />
</property>
<property name="rpiPercentage">
<column name="rpi_percentage" not-null="true" sql-type="money" />
</property>
<property name="totalRoyalty">
<column name="total_royalty" not-null="true" sql-type="money" />
</property>
<property name="thirdPartyPercentage">
<column name="third_party_percentage" not-null="true" sql-type="money" />
</property>
<many-to-one name="renewalAccount" column="renewal_account_id" not-null="true" />
</class>
<class name="com.qas.newmedia.internet.renewals.dto.Payment"
table="tblPayments"
discriminator-value="Payment">
<id name="id" type="int" column="payment_id" unsaved-value="0">
<generator class="identity" />
</id>
<discriminator column="payment_type" type="string" />
<subclass
name="com.qas.newmedia.internet.renewals.dto.CreditCardPayment"
discriminator-value="CreditCard">
<property name="type" column="type" not-null="false" />
<property name="number" column="number" not-null="false" />
<property name="expiryDate" column="expiry_date" not-null="false" />
<property name="securityNumber" column="security_number" not-null="false" />
<property name="nameOnCard" column="name_on_card" not-null="false" />
<property name="issueNumber" column="issue_number" not-null="false" />
</subclass>
<subclass
name="com.qas.newmedia.internet.renewals.dto.InvoicePayment"
discriminator-value="Invoice">
<property name="purchaseOrderNumber" column="purchase_order_number" not-null="false" />
</subclass>
</class>
<class name="com.qas.newmedia.internet.renewals.dto.Contact"
table="tblContacts"
discriminator-value="Contact">
<id name="id" type="int" column="contact_id" unsaved-value="0">
<generator class="identity" />
</id>
<discriminator column="contact_type" type="string" />
<property name="title" column="title" not-null="false" />
<property name="firstName" column="first_name" not-null="false" />
<property name="initial" column="initial" not-null="false" />
<property name="lastName" column="last_name" not-null="false" />
<property name="telephoneNumber" column="telephone_number" not-null="false" />
<property name="email" column="email" not-null="false" />
<many-to-one name="address" class="com.qas.newmedia.internet.renewals.dto.Address" column="address_id" />
<subclass
name="com.qas.newmedia.internet.renewals.dto.EmployeeContact"
discriminator-value="Employee">
<property name="jobDescription" column="job_description" not-null="false" />
<property name="department" column="department" not-null="false" />
<property name="companyName" column="company_name" not-null="false" />
</subclass>
</class>
<class name="com.qas.newmedia.internet.renewals.dto.Address"
table="tblAddresses"
discriminator-value="Address">
<id name="id" type="int" column="address_id" unsaved-value="0">
<generator class="identity" />
</id>
<discriminator column="address_type" type="string" />
<property name="line1" column="line1" not-null="false" />
<property name="line2" column="line2" not-null="false" />
<property name="line3" column="line3" not-null="false" />
<property name="line4" column="line4" not-null="false" />
<property name="line5" column="line5" not-null="false" />
<property name="line6" column="line6" not-null="false" />
<subclass
name="com.qas.newmedia.internet.renewals.dto.ChangeableAddress"
discriminator-value="Changeable">
<property name="reasonForChange" column="reason_for_change" not-null="false" />
</subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
renewalAccount = (RenewalAccount) (session.find(
"from RenewalAccount as ra where ra.loginId = ?",
id,
Hibernate.STRING
)).get(0);
Full stack trace of any exception that occurs:N/A
Name and version of the database you are using:SQL Server 2000
Debug level Hibernate log excerpt:Code:
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.loader.Loader:605) - Hydrating entity: com.qas.newmedia.internet.renewals.dto.Address#1563
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:68) - returning '64 Clarendon Road' as column: line10_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:68) - returning '64 Clarendon Road' as column: line10_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:64) - returning null as column: line20_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:64) - returning null as column: line20_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:64) - returning null as column: line30_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:64) - returning null as column: line30_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:68) - returning 'WATFORD' as column: line40_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:68) - returning 'WATFORD' as column: line40_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:64) - returning null as column: line50_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:64) - returning null as column: line50_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:68) - returning 'WD17 1DA' as column: line60_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.type.NullableType:68) - returning 'WD17 1DA' as column: line60_
2004-08-25 12:09:29,367 - DEBUG (net.sf.hibernate.loader.Loader:536) - Initializing object from ResultSet: 1563
the dehydration seems to move the columns about .. notice that line60_ is now bound to parameter 1!!
Code:
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.persister.EntityPersister:388) - Dehydrating entity: [com.qas.newmedia.internet.renewals.dto.Address#1564]
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:46) - binding 'WD17 1DA' to parameter: 1
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:46) - binding 'WD17 1DA' to parameter: 1
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 2
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 2
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 3
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 3
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 4
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 4
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 5
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 5
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 6
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:41) - binding null to parameter: 6
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:46) - binding '1564' to parameter: 7
2004-08-25 12:09:29,461 - DEBUG (net.sf.hibernate.type.NullableType:46) - binding '1564' to parameter: 7
2004-08-25 12:09:29,758 - DEBUG (net.sf.hibernate.persister.EntityPersister:648) - Updating entity: [com.qas.newmedia.internet.renewals.dto.Address#1563]