0 Replies Latest reply on Oct 2, 2006 3:29 PM by flo thomas

    auto generated ids

    flo thomas Newbie

      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?