[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - auto generated ids
do-not-reply at jboss.com
Mon Oct 2 15:29:13 EDT 2006
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?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3975587#3975587
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3975587
More information about the jboss-user