-->
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.  [ 1 post ] 
Author Message
 Post subject: Assigned Id for a class mapped with generated id
PostPosted: Wed Sep 09, 2009 5:27 am 
Newbie

Joined: Wed Sep 09, 2009 3:26 am
Posts: 2
Hi all,

My problem is :
I've a class A mapped with the following annotations :
@Id
@GeneratedValue(generator = "uddi-id")
@GenericGenerator(name = "uddi-id", strategy = "myapp.persistence.util.UDDIIdentifierGenerator")

If I save an object of type A with Id = null, all is ok, id is generated by my custom generator and object is persisted.

The problem is when I try to persist an object of type A with an application (and not an hibernate) generated Id. In this case hibernate try to update this object instead of creating it (the saveOrUpdate case) or persist it with a generated id instead of my application created id (the merge/persist case).

So my question is : is it possible to persist the same type of object (with the same annotation), once with a generated id (if the id of the object to persist is null) and once with an application assigned id ? And how could I do that ?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.