Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring + Hibernate: how to have a configurable PK generator?
    primarykey
    data
    text
    <p>We use Spring + Hibernate for a Webapp.</p> <p>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.</p> <p>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.</p> <p>A further constraint imposed to me is that these PKs fit in a <code>Long</code>, so I can't use UUIDs.</p> <p>What I'm trying to do is to change the current hibernate mapping, that has sequence <code>S_PERSON</code> as generator:</p> <pre><code>&lt;hibernate-mapping default-cascade="save-update" auto-import="false"&gt; &lt;class name="com.some.domain.Person" abstract="true"&gt; &lt;id name="id"&gt; &lt;column name="PERSON_ID"/&gt; &lt;generator class="sequence"&gt; &lt;param name="sequence"&gt;S_PERSON&lt;/param&gt; &lt;/generator&gt; &lt;/id&gt; ... &lt;/hibernate-mapping&gt; </code></pre> <p>into something configurable, so that <code>PERSON_ID</code> have its PKs generated from different sequences (maybe <code>S_PERSON_1</code> and <code>S_PERSON_2</code>) depending on the deployment site's Spring configuration files.</p> <p>Of course,</p> <pre><code> &lt;generator class="sequence"&gt; &lt;param name="sequence"&gt;${sequenceName}&lt;/param&gt; &lt;/generator&gt; </code></pre> <p>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...</p> <p>Any ideas or workaround?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload