Announcement Announcement Module
No announcement yet.
how to set explicit id instead of generated id ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to set explicit id instead of generated id ?

    I am using Spring with Hibernate. I am really pleased with Spring, but I have hit a hurdle. I have a bean defined with a generated ID field, e.g.

    @GenericGenerator(name="system-uuid", strategy = "uuid")
    public String getOrganisationID()
    return organisationID;

    Everything works fine with the ids being generated automatically, but there are some instances where I want to use a specific id value instead of the generated value. Any attempt to set the value before calling is ignored and the generator replaces my value with the generated value. I agree that this is correct behaviour, but I wonder is there any (easy) way to override the generated value on save ?

    many thanks

  • #2
    I was able to overcome this by instead using a HQL insert statement, which bypasses the auto key generation.