Hi I am using Hibernate 3.0 i i have got this code:
Code:
anu.setEmpleado(empl);
depto.addAnuncio(anu);
session.beginTransaction();
session.update(depto);
session.getTransaction().commit();
session.close();
the exception:
Code:
org.hibernate.TransientObjectException: model.Empleado
org.hibernate.TransientObjectException: model.Empleado
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1826)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2172)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
the mappings are:
Code:
<class name="model.calidad.Aviso" table="Aviso">
<id name="aviso_id" column="aviso_id">
<generator class="increment"/>
</id>
<property name="nombre" type="string"/>
<property name="descripcion" type="string"/>
<property name="fecha" type="java.util.Date"/>
<property name="envioEmail" type="boolean"/>
<many-to-one name="empleado" column="empleado_id" lazy="false" cascade="persist" class="model.Empleado"></many-to-one>
<set lazy="false" cascade="all" name="comentarios">
<key column="aviso_id"/>
<one-to-many class="model.calidad.Comentario"/>
</set>
Code:
<class name="model.Departamento" table="Departamento" >
<id name="departamento_id" column="departamento_id">
<generator class="increment"/>
</id>
<property name="descripcion" type="string"/>
<property name="nombre" type="string"/>
<set name="puestos" cascade="all" lazy="false" >
<key not-null="true" column="departamento_id"/>
<one-to-many class="model.Puesto"/>
</set>
<set name="anuncios" cascade="all" lazy="false" >
<key not-null="true" column="departamento_id"/>
<one-to-many class="model.calidad.Anuncio"/>
</set>
</class>
It has Anyone an idea? thanks a lot