Hi all,
i have a problem. I have this two hbm.conf:
tUsuarios.hbm.xml
Code:
<hibernate-mapping package="bbdd.modelos">
<class name="tUsuarios"
table="usuarios" lazy="true">
<!-- Common id property. -->
<id name="Num_Emple"
type="int"
column="num_emple"
unsaved-value="0">
<generator class="native"/>
</id>
<!-- A versioned entity. -->
<property name="Clave"
type="string"
column="clave"
not-null="true"/>
<!-- Name of the item is immutable. -->
<property name="FechaPassword"
type="date"
column="fecha"
not-null="true"/>
<!-- Limit item description to 4000 characters, Oracle. -->
<property name="Id_Perfil"
type="int"
column="id_perfil"
not-null="true"/>
<one-to-one name="DPersonales" class="tDPersonales" constrained="true"/>
<one-to-one name="Perfil" class="tPerfiles" constrained="true"/>
</class>
</hibernate-mapping>
tPerfiles.hbm.xmlCode:
<hibernate-mapping package="bbdd.modelos">
<class name="tPerfiles" table="perfiles">
<id name="Id_Perfil">
<generator class="sequence">
<param name="sequence">perfiles_id_perfil_seq</param>
</generator>
</id>
<property name="Id_Permiso"/>
<property name="Centro"/>
<property name="Descripcion"/>
</class>
</hibernate-mapping>
Relations between Usuarios and DPersonales works okey because they have the same primary key.
Problems become with Perfiles, because in Usuarios, Perfiles primary key is a foreign key. I was reading hibernate reference but i have no idea on making tUsuarios using a foreign key with tPerfiles. I know that the error code is a problem of this cause.
Error code is like that:
Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [bbdd.modelos.tPerfiles#82012]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:118)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:75)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:639)
82012 is Num_Emple data and with DPersonales match okey, but isn't write for Perfiles.
Thanks a lot