-->
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: version and timestamp not supported?
PostPosted: Wed Dec 21, 2005 7:04 pm 
Newbie

Joined: Wed Dec 21, 2005 6:58 pm
Posts: 1
I'm using nhibernate 1.0.1 and I'm not able to use the timestamp or version tags in my xml. I can declare my timestamp field like this:

<property name="LastUpdated" column="updated_dt" type="Timestamp"/>

but not like this:

<version name="LastUpdated" column="updated_dt" type="Timestamp"/>
<timestamp name="LastUpdated" column="updated_dt"/>

Of course, declaring it as a property doesn't do what I want it to do.

Here's the exception that version gives me (similar for <timestamp>):

{"NHibernate.MappingException exception was thrown : 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'."}

Am I missing something? I've looked high and low and can't figure it out. It works when I use NHibernate.Mapping.Attributes and put a timestamp or version attribute on the property. For some reason, however, it doesn't think either are in the XML schema when it parses my *.hbm.xml files. Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 9:04 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
pretty sure <version> is an Int32 and not a Timestamp. Being obvious, but you can't use both. One or the other. Either:
Code:
<version name="Version" Type="int32" unsaved-value="-1" />


- or -

Code:
<timestamp name="LastUpdated" column="updated_dt" />


-devon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 9:23 pm 
Regular
Regular

Joined: Mon May 16, 2005 1:35 am
Posts: 67
The <version> element needs to go above all your <property> elements in your mapping file. So directly below the <id> element (or the <discriminator> element if there is one).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 10:15 pm 
Thanks baggins, that was the problem. I put it first and it works perfectly. Thanks also to devonl for the clarification on the differnce between timestamp and version.


Top
  
 
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.