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
|