-->
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.  [ 2 posts ] 
Author Message
 Post subject: parent/child relationship problems
PostPosted: Tue Jul 18, 2006 12:51 am 
Newbie

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 11:37 am 
Newbie

Joined: Thu Jul 06, 2006 9:54 am
Posts: 8
hey fellows
i have realized what my errors was
here i made a mistake (as newbie of course)


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

hibernate was trying to access the parent id and here must be the child id
sorry


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

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.