-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with mapping
PostPosted: Fri Jul 01, 2005 5:56 am 
Beginner
Beginner

Joined: Wed May 18, 2005 9:48 am
Posts: 31
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.xml

Code:
<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


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

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.