-->
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: Generated Ids
PostPosted: Mon Oct 02, 2006 3:29 pm 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
Hi,
I have a question regarding GeneratedIds, I have a property of my mapped class (it has 2 props: String content & @Id @GeneratedValue Long id) - the string should be unique, it could contain up to 255 chars. However, I expect often that data is entered which is already persistent, so I use merge() instead of persist(). Now, merge() seems to work only if I have an id set, i.e. there is already an object in the DB (1,"hello") and I create a new Object(,"hello") and want to merge it, then I get a ConstraintViolationException - if I leave out the Long id and use the "hello" as the Id (via @Id), then it works - however then I have so much redundant data - e.g. if I use the String content as a Foreign Key, all the other tables will also have this 255 char string inside instead of a tiny number... is there any other way I can do this?

Thanks,
Joey


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.