Joined: Thu Jul 06, 2006 9:54 am Posts: 8
|
hi follow what i put bellow and help to find what i am doing wrongç
i j ust try toi follow the steps in the documentation but i got a big error
Hibernate version:
3.2 beta6
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 10-jul-2006 3:51:12 by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="zun.inventario.commons.model.data.Grupo" table="A_Grupo" lazy="false">
<id name="codG" type="string">
<column name="cod_G" length="5" />
<generator class="assigned" />
</id>
<set name="Familias"
inverse="true"
cascade="all-delete-orphan">
<key>
<column name="cod_G" length="5" />
</key>
<one-to-many class="zun.inventario.commons.model.data.Familia" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 10-jul-2006 3:51:12 by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="zun.inventario.commons.model.data.Familia" table="A_Familia" lazy="false">
<id name="idF" type="int"
unsaved-value="-1">
<column name="id_F" />
<generator class="identity" />
</id>
<many-to-one name="Grupo"
class="zun.inventario.commons.model.data.Grupo"
fetch="select"
not-null="true"
insert="false"
update="false">
<column name="cod_G" length="5" />
</many-to-one>
<set name="Productos" inverse="true">
<key>
<column name="id_F" not-null="true" />
</key>
<one-to-many class="zun.inventario.commons.model.data.Producto" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Grupo g = (Grupo)se.load(Grupo.class,"tvs");
Familia f = new Familia();
g.AddFamilia(f);// like HIA says
se.saveOrUpdate(g);
Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.HibernateException: Unexpected row count: 0 expected: 1
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:33)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2203)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2117)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2373)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:908)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:344)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
Name and version of the database you are using:
SqlSever SPK3
|
|