Oracle11g-HSQLDB [message #813629] |
Mon, 05 March 2012 09:28  |
Eclipse User |
|
|
|
I want to move a DB structure from Oracle 11g to HSQLDB embedded throught java code.
I create the Oracle DB in SQL Developer, then mapping the DB throught NetBeans in java class.
Now I want to create from this structure an embedded DB in HSQLDB at the run of my application.
I have a problem with a primary key generate in oracle with an trigger-sequence (auto-increment).
For the oracle 11g I identify the column with the tag @ReturnInsert, to have the value of the primary key returned after the persist command, but that isn't supported for the HSQLDB, and then the HSQLDB don't have defined the sequence-trigger elements.
The creation of HSQLDB from the java code works fine if instead of @ReturnInsert I used
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="EMP_SEQ")
@SequenceGenerator(name="EMP_SEQ", sequenceName="EMP_SEQ", allocationSize=100)
but this code isn't correct for me to use in OracleCode because i want to use the trigger for my centralized db (oracle).
There is a way to customize my java class entity to define in different way the same field (primary key)???.
Someone can suggest my how to work?
|
|
|
Re: Oracle11g-HSQLDB [message #813747 is a reply to message #813629] |
Mon, 05 March 2012 12:06  |
Eclipse User |
|
|
|
You would be better off using the same sequence generator in Oracle, than using your trigger assigned sequence. It would be much more efficient.
If you want to have different metadata for different databases, you can use a different persistence unit, or persistence.xml and add any changes in an orm.xml.
You could also modify the ClassDescriptors in code using a DescriptorCustomizer, or SessionCustomizer depending on what database you are connecting to.
|
|
|
Powered by
FUDForum. Page generated in 0.03572 seconds