-->
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: Question about generator type="identity"
PostPosted: Mon Nov 21, 2005 12:07 pm 
Newbie

Joined: Mon Nov 21, 2005 11:05 am
Posts: 2
Hi
I posted this query on the wrong board:
I wrote:
Is it possible to set the identity field of an entity and have session.save persist the class using the specified value for the identity field ? Currently it just seems to be ignoring the value, using the new one retrieved from the mysql auto_increment id field instead.

I know it's not the normal behaviour but for running unit tests driven by data loaded from csv's for example it is by far the easiest way of doing things.

And got in reply

emmanuel wrote:
this is not an ejb3 question.
use generator="assigned"


to which I would like to continue with...

I would rather not change the generator to "assigned" because then the auto number creation would not happen when running under normal conditions if I understand it correctly. Ideally the number would be taken from the auto_increment when zero, and otherwise taken as if the generator was "assigned" when non-zero. Is the only solution to create my own generator ?

David


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 12:19 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
AFAIK, yes. Write your own generator method and use id=assigned. Should work fine.

_________________
Don't forget to rate if the post helped!


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.