-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Combination of 'id' and 'composite-id' possible ?
PostPosted: Tue Dec 14, 2004 8:58 am 
Newbie

Joined: Tue Dec 14, 2004 8:30 am
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 4:50 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
You can use oracle trigger

regards
Peco


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.