-->
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: @Id application assigned
PostPosted: Tue Oct 03, 2006 12:45 am 
Newbie

Joined: Tue Mar 21, 2006 1:29 pm
Posts: 9
Hi,

In Hibernate it is possible to have an Id assigned by the application, is possible too with Hibernate Annotation and Hibernate EM.

In fact, I would like to assign myself the Id for an entity, because those entities are master data and I would like to the same ids accross different databases.

If I use only @Id, I got an error saying that my entity is transient (normal)

if I use

Code:
   @Id
   @GeneratedValue(generator="app-assigned")
   @GenericGenerator(name = "app-assigned", strategy = "assigned")


I got the error saying that a detach entity passed to persist (normal).

Then I use merge, but in this case I have again the error transient.

So, could someone tell what is the @Id setup I have to use to set the Id myself (in my application)?

Thanks
Dominique


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 4:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
do not use a @GeneratedValue if you want to assign it ;-)

Code:
@Id private Long id;

_________________
Emmanuel


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.