Hibernate version: 3.05
Mapping documents:
<hibernate-mapping package="cr.go.ice.gescom.domain">
<class name="Cliente" table="CLIENTE">
<id name="idCliente" type="long" column="IDCLIENTE">
<generator class="sequence">
<param name="sequence">CLIENTE_ID_SEQ</param>
</generator>
</id>
<property name="identificacionCliente" column="IDENTIFICACIONCLIENTE" type="string" not-null="true"/>
</class>
</hibernate-mapping>
<hibernate-mapping package="cr.go.ice.gescom.domain">
<class name="RutaCobro" table="RUTACOBRO">
<id name="idRutaCobro" column="IDRUTACOBRO">
<generator class="sequence">
<param name="sequence">RUTACOBRO_ID_SQ</param>
</generator>
</id>
<property name="numeroApartado" column="NUMEROAPARTADO" type="string" not-null="true"/>
<property name="zonaPostal" column="ZONAPOSTAL" type="string" not-null="true"/>
<property name="rutaCobro" column="RUTACOBRO" type="integer" not-null="true"/>
<one-to-one name="cliente" foreign-key="IDCLIENTE" class="Cliente"/>
</class>
</hibernate-mapping>
Name and version of the database you are using: Oracle 9i
There is an object called "Cliente" which, in some cases, may had a "RutaCobro" object. I had defined this like a many-to-one relationship on the data base, for example:
- table Cliente:
- idCliente PK
- table RutaCobro:
- idRutaCobro PK
- idCliente FK
I now that that is not the best option... and what I really want to do is this:
- table Cliente:
- idCliente PK
- table RutaCobro
- idCliente PK, FK
So I now that there is only one "RutaCobro" for every "Cliente" that needs it. I don't had find any solution to this in hibernate, maybe I just couldn't undestand how to apply a one-to-one relationship in a object level.
there is anyway to do what I need to do? Can I make the following:
Code:
cliente.getRutaCobro()
and hopefully that does not give me a nullPointerException on those "Cliente" that does not has that property.
my case is clear somehow?
thanks.
jorge f.