Hi there,
I'm trying to find the correct mapping for the following situation:
I have a table which looks like this:
UPLOAD_ID NUMBER(8) not null
UPLOAD_BEG_DATE DATE not null
UPLOAD_RUN_ID NUMBER(8) not null
UPLOAD_RECORD_ID NUMBER(8) not null
The hibernate-mapping currently looks like this:
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="... Upload" table="UPLOAD">
<composite-id>
<key-property name="uploadBegDate" column="UPLOAD_BEG_DATE" type="java.util.Date" length="7"/>
<key-property name="uploadId" column="UPLOAD_ID" type="java.lang.Integer" length="8"/>
<key-property name="uploadRecordId" column="UPLOAD_RECORD_ID" type="java.lang.Integer" length="8"/>
<key-property name="uploadRunId" column="UPLOAD_RUN_ID" type="java.lang.Integer" length="8"/>
</composite-id>
</class>
</hibernate-mapping>
Name and version of the database you are using:
Oracle
This looks all good to me, but I now have the requirement, that the uploadRecordId needs to be generated by a ORACLE-Sequence.
If I would not have it as a composite-id, I would have something like this:
<id name="uploadRecordId" type="long" column="UPLOAD_RECORD_ID" unsaved-value="0">
<generator class="sequence">
<param name="sequence">RECORD_ID_SEQ</param>
</generator>
</id>
Since I need both, the generated property and the composite-ID my question is now,
if there's any possibility to combine these two approaches ?
Any idea ?
Thanks in advance,
Dirk
|