-->
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: Updating a column from a sequence
PostPosted: Wed Feb 22, 2006 5:28 pm 
Newbie

Joined: Wed Feb 22, 2006 5:15 pm
Posts: 2
Hi

I am developing an application that needs to be replicated down to a mobile device. To do this I need a column in each table that is updated with a sequence number.

Try as I might I cannot find hwo to do thsi in the docs, the Book, or the forum.

So the question is.

How do I map a property so that when ever the object is saved the property is updated from a sequence?

Any help greatly appreciated.

Regards

Richard Spence


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 12:40 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Use the <version> element. If you turn on generated="true" it effectively becomes a sequence/identity value.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 1:59 am 
Newbie

Joined: Wed Feb 22, 2006 5:15 pm
Posts: 2
Thanks for your reply but things are still not clear.

The version element has the following syntax

<version
column="version_column" (1)
name="propertyName" (2)
type="typename" (3)
access="field|property|ClassName" (4)
unsaved-value="null|negative|undefined" (5)
node="element-name|@attribute-name|element/@attribute|."
/>

I can't see how to add a generated=true.

Could you point me to an example?

Thanks again

Richard Spence


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 5:09 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The generated element is new to 3.1. You didn't specify which versoin you're using, so I guessed. Wrong, obviously :). For earlier versions, you can create your identity or sequence column in your DB, and specify it in your mapping using <property name="whatever" formula="columnname"/>. It's nearly as good.

BTW, I made a booboo, it's 'generated="always"', not ="true".


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