We use Spring + Hibernate for a Webapp.
This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel.
What I need to do, is to make sure that the Persons generated on these two unrelated production sites all have distinct PKs, so that we can merge the Person data from these two sites at any time.
A further constraint imposed to me is that these PKs fit in a Long
, so I can't use UUIDs.
What I'm trying to do is to change the current hibernate mapping, that has sequence S_PERSON
as generator:
<hibernate-mapping default-cascade="save-update" auto-import="false">
<class name="com.some.domain.Person" abstract="true">
<id name="id">
<column name="PERSON_ID"/>
<generator class="sequence">
<param name="sequence">S_PERSON</param>
</generator>
</id>
...
</hibernate-mapping>
into something configurable, so that PERSON_ID
have its PKs generated from different sequences (maybe S_PERSON_1
and S_PERSON_2
) depending on the deployment site's Spring configuration files.
Of course,
<generator class="sequence">
<param name="sequence">${sequenceName}</param>
</generator>
doesn't work, so I have to figure out something else... I guess my generator should point to a configurable bean that in turn points to a sequence or another, but I can't figure how to do that...
Any ideas or workaround?
Thanks!