-->
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.  [ 4 posts ] 
Author Message
 Post subject: Empty collections using PK with sequence
PostPosted: Thu Dec 22, 2005 7:30 am 
Newbie

Joined: Thu Apr 22, 2004 4:19 am
Posts: 6
Hi,
I've a database table whose primary key is composed by a varchar column and an oracle sequence (yes, that's right). Also, this table has many-to-one relationships. The hibernate mapping file is (hidding irrelevant information):

<class name="Caextexped" table="CAEXTEXPED">
<id name="id" type="es.clientapp.data.hibernate.types.ExpedientePkType">
<column name="CENCOL" length="4" not-null="true" />
<column name="CNEXPE" precision="10" scale="0" not-null="true" />
<generator class="es.clientapp.data.hibernate.generators.ExpedienteIdGenerator">
<param name="sequence">CAPACEX.CAEXNEXPED</param>
</generator>
</id>

<set name="caextdocprs">
<key>
<column name="CENCOL" length="4" not-null="true" />
<column name="CNEXPE" precision="10" scale="0" not-null="true" />
</key>
<one-to-many class="Caextdocpr" />
</set>
</class>


The fact is that I can do operations like save, load or update on Caextexped entity and it works fine, but when I try to get the collection named caextdocprs, I get an empty one. But surprisingly, I see in the logs that hibernate retrieves all the data of the collection, but I can't understand why the data retrieved isn't assigned to the entity collection. I think it has something to do
with the primary key, because if I change it to:

<composite-id name="id" class="CaextexpedId">
<key-property name="cencol" type="string">
<column name="CENCOL" length="4" />
</key-property>
<key-property name="cnexpe" type="long">
<column name="CNEXPE" precision="10" scale="0" />
</key-property>
</composite-id>


everything works fine. But this mapping does not fullfill my requirements (composed PK + Oracle sequence).
Maybe the particular primary key definition in the first case, affects in some manner the way the collection must be defined?!?
Any idea how I can get the collection data using the first primary key mapping?

Thanks a lot for any hint!

PD: I'm using Hibernate 3.0.5


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 22, 2005 8:26 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Did you try to use composite-id instead of id for Caextexped ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 4:15 am 
Newbie

Joined: Thu Apr 22, 2004 4:19 am
Posts: 6
With composite-id I can't specify a generator class


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 6:44 am 
Beginner
Beginner

Joined: Tue Sep 20, 2005 4:32 am
Posts: 29
Location: Cluj-Napoca
Hi Zokor,

I'm interested in creating a custom generator class.

Can you send me please an example of how you write the class es.clientapp.data.hibernate.generators.ExpedienteIdGenerator ?

Thanks a lot,
Cristian.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.