-->
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.  [ 2 posts ] 
Author Message
 Post subject: Differences between RC1 and RC3 - bug?
PostPosted: Thu Oct 06, 2005 8:22 pm 
Newbie

Joined: Mon Jun 20, 2005 8:47 pm
Posts: 11
Hi,

I have had an issue with code that worked in RC1 that now exhibits different behaviour under RC3.

Specifically, the result of the "version unsaved value" in the AbstractEntityPersister( PersistentClass model, ISessionFactoryImplementor factory ) method is different.

In RC1 I get a unsavedVersionValue.Value = null.

In RC3 I get a unsavedVersionValue.Value = int.MinValues.

So what does this mean for me? Well given these mappings:

Code:

<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="XXX.BusinessEntities" assembly="XXX">

   <class name="LicenceDetail" table="LicenceDetails" dynamic-update="true">
       
        <id name="Id" column="LD_ID"  type="Int32"  >
            <generator class="identity" />
        </id>

      <!-- Standard Audit Properties -->
      <version name="RowVersion" column="RowVersion" type="Int32"  />
      <property name="CreationUser" column="CreationUser" type="String" />
      <property name="CreationDateTime" column="CreationDateTime" type="DateTime" />
      <property name="LastUpdateUser" column="LastUpdateUser" type="String" />
      <property name="LastUpdateDateTime" column="LastUpdateDateTime" type="DateTime" />
        <!-- End -->
      
         <property name="Status" column="LD_Status" type="String" />
         <property name="DateIssued" column="LD_dateIssued" type="DateTime" />
         <property name="DateSurrendered" column="LD_dateSurrendered" type="DateTime" />
         <property name="DateTransferred" column="LD_dateTransferred" type="DateTime" />
         <property name="DateSuspFrom" column="LD_dateSuspFrom" type="DateTime" />
         <property name="DateSuspTo" column="LD_dateSuspTo" type="DateTime" />
         <property name="MachinesApproved" column="LD_machinesApproved" type="Int16" />
      
   </class>
</hibernate-mapping>


and

Code:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="XXX.BusinessEntities" assembly="XXX">

   <class name="LinkedLicence" table="LinkedLicences" dynamic-update="true">
       
        <id name="Id" column="LNK_ID" type="Int32">
            <generator class="identity" />
        </id>

      <!-- Standard Audit Properties -->
      <version name="RowVersion" column="RowVersion" type="Int32" />
         <property name="CreationUser" column="CreationUser" type="String" />
         <property name="CreationDateTime" column="CreationDateTime" type="DateTime" />
         <property name="LastUpdateUser" column="LastUpdateUser" type="String" />
         <property name="LastUpdateDateTime" column="LastUpdateDateTime" type="DateTime" />
         <!-- End -->

        <many-to-one name="LicenceDetail" column="LNK_LD_ID_Parent" insert="true" update="true" />

   </class>


The following code used to work in RC1:

Code:
LinkedLicence linked = new LinkedLicence();
LicenceDetail detail = new LicenceDetail();
detail.Id = 7856;
linked.LicenceDetail = detail;
session.FlushMode = FlushMode.Commit;
session.BeginTransaction();
session.SaveOrUpdate(linked);
session.Transaction.Commit();


It resulted in an insert statement that included the foreign key 7856 for the column LNK_LD_ID_Parent.

However with RC3, the LNK_LD_ID_Parent resolves to NULL because Hibernate thinks that it is unsaved.

So, is this a bug, design feature or what can I do to resolve this issue?

BTW, my RowVersion property defaults to int.MinValues in my class.

I can work around the issue by specifying a

Code:
detail.RowVersion = 0;


Which results in Hibernate thinking I have a saved entity and the key is used as per RC1.

Cheers,

Mike :shock:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 4:59 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This is probably due to the unsaved-value guessing feature introduced in RC2. If unsaved-value is not specified in the mappings, NH will guess it by creating a new uninitialized object and reading its version value. Same for IDs.


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