Hi all
I'm struggling with an issue concerning automatic primary key generation. There is nothing special so far with my primary keys, they're just simple data types. The type is Numeric on a SQL Server and on an Oracle instance. both databases are prepared to autoincrement the primary key.
But... here comes the problem. The excerpt of my XML mapping file shows that I use
native for utmost flexibility.
Code:
...
<id name="ItemId" column="ITEM_ID" type="Decimal" unsaved-value="0">
<generator class="native"/>
</id>
...
On the SQL Server everything is working fine. But when I switch to Oracle this configuration asks the database to recieve the new primary key value from a sequence called
hibernate_sequence but of course there is no such sequence because every table has its own one.
To avoid this I can use the following XML configuration for Oracle
Code:
...
<id name="ItemId" column="ITEM_ID" type="Decimal" unsaved-value="0">
<generator class="sequence">
<param name="sequence">itm_seq</param>
</generator>
</id>
...
So far this works fine. Though I wonder if it's possible to use
native in the XML mapping file for Oracle too
and use the correct sequence for each table. Is something like this possible or do I have to change the XML mapping file when I switch the database?
Thanks in advance,
Chavez