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: <version> == DateTime??? Why?
PostPosted: Thu Jun 02, 2005 10:21 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
greetings,

started moving my objects from the <timestamp> versioning to <version> versioning and discovered that in NH <version> maps to a datetime? why did we choose to implement it that way as oposed to following the Hibernate strategy of offering the version as an int?

it is conceivable that two concurrent transactions could load and update the same object at the same time. even down to the millisecond. i was hoping to use <version> to avoid this....

TIA,

-devon


Top
 Profile  
 
 Post subject: RE: <version> == DateTime??? Why?
PostPosted: Fri Jun 03, 2005 1:27 am 
IVersionType appears to be supported by Int32Type - do you have a type specified in your <version> element?

It's not just that the concurrent transactions may run at the same time. The IVersionType implementations in DateTimeType.cs and TimestampType.cs appear to just return DateTime.Now - not a great option if you have NH running on multiple hosts, or modify the db with code that uses the db server clock.

I'm probably starting to sound like a stuck record, but is there any way to use database generated row versions for concurrency checks rather than NH assigning the new value? Anyone?

Cheers,
Sam


Top
  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 1:57 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
indeed i do have version set properly:

Code:
<hibernate-mapping
   xmlns="urn:nhibernate-mapping-2.0"
   namespace="AMA.Core.Domain"
   assembly="AMA.Core">

   <class
      name="Survey"
      table="Survey"
      proxy="Survey"
      dynamic-insert="true"
      dynamic-update="true">
      
      <jcs-cache usage="read-write" />

      <id name="id" column="SurveyID" type="Int32" unsaved-value="-1" access="field">
         <generator class="identity" />
      </id>
      
      <version name="version" column="Version" type="Int32" unsaved-value="0" access="field" />
      
      <property name="Name" column="Name" type="String" not-null="true" />
      <property name="DateCreated" column="DateCreated" type="DateTime" not-null="true" update="false" access="nosetter.camelcase" />
      <property name="LastUpdate" column="LastUpdate" type="DateTime" not-null="true" />      
      
      <list name="Questions" cascade="all-delete-orphan" lazy="true">
         <key column="SurveyID" />
         <index column="DisplayOrder" type="Int32" />
         <one-to-many class="Question" />
      </list>
      
   </class>

</hibernate-mapping>


believe it or not, i stepped away form the computer for dinner and when i returned, it was working. not sure what or why. my envirnoment has been acting flakely lately....

thanks for the post.

-devon


Top
 Profile  
 
 Post subject: Error while using <version>
PostPosted: Tue Jul 18, 2006 3:14 am 
Beginner
Beginner

Joined: Tue Feb 28, 2006 3:16 am
Posts: 28
It do not takes version property in my mapping
========================
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" >
<class name="MyNewBagHierarchyWork.NodeRelation,MyNewBagHierarchyWork" table="Hie_AcctRelations" >
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="Weight" column="Weight" not-null="false" />
<property name="Position" column="Pos" type="Int32" insert="true" update="true" not-null="true" />
<!-- this parent is needed to avoid having "allow Nulls" in the Parent ID column in the table (Something missing in NHibernate)-->
<many-to-one name="Parent" column="ParentID" class="MyNewBagHierarchyWork.NodeBase, MyNewBagHierarchyWork" not-null="true" />
<many-to-one name="Node" column="ChildID" class="MyNewBagHierarchyWork.NodeBase, MyNewBagHierarchyWork" insert="true" update="true" cascade="all-delete-orphan" />
<version name="version" column="Version" type="Timestamp" unsaved-value="0" access="field" />

</class>
</hibernate-mapping>
====================
It gives following error

The element 'class' in namespace 'urn:nhibernate-mapping-2.0' has invalid child element 'version' in namespace 'urn:nhibernate-mapping-2.0'. List of possible elements expected: 'urn:nhibernate-mapping-2.0:property urn:nhibernate-mapping-2.0:many-to-one urn:nhibernate-mapping-2.0:one-to-one urn:nhibernate-mapping-2.0:component urn:nhibernate-mapping-2.0:dynamic-component urn:nhibernate-mapping-2.0:any urn:nhibernate-mapping-2.0:map urn:nhibernate-mapping-2.0:set urn:nhibernate-mapping-2.0:list urn:nhibernate-mapping-2.0:bag urn:nhibernate-mapping-2.0:idbag urn:nhibernate-mapping-2.0:array urn:nhibernate-mapping-2.0:primitive-array urn:nhibernate-mapping-2.0:subclass urn:nhibernate-mapping-2.0:joined-subclass'.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 5:24 am 
Newbie

Joined: Wed Apr 26, 2006 3:18 pm
Posts: 8
pcmedsinge,

the version details must be placed directly under the ID details, that is why in this case it is failing.


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.