Announcement Announcement Module
Collapse
No announcement yet.
"promote" entity from one database to another Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • "promote" entity from one database to another

    Folks,

    I have a situation where I need to provide "promote" functionality where Vendor data from pre-production database is copied to production database. I am using Spring 2 + JPA + Hibernate 3.2. So, I find the Vendor entity from pre-prod and pass it to the production entity manager to persist. The data is saved to production database but there is one problem. In entity Vendor, the Id uses GeneratedValue with strategy=sequence. Due to this when the Vendor is saved in production, it is treated as a "new" entity and is assigned a new vendor id from the sequence (which is different from vendor id in pre-prod). The requirement is to have the same Vendor Id in pre-prod and production databases. What are the possible ways to accomplish this? Is there a way I can override the GeneratedValue to get a new sequence value only if Id is null?

    TIA,
    Sameer
Working...
X