-->
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: Problems with save childs in one to many relationships
PostPosted: Tue Aug 31, 2004 9:44 am 
Newbie

Joined: Tue Aug 31, 2004 9:22 am
Posts: 6
I have a 'one-to-many' relationship between the class NotaPedido (one) and ItemNotaPedido (many). Both classes have id generator class = increment.
When i have an empty database, and i save the pojo NotaPedido with its childs ItemNotaPedido, that work OK.
But, when i want to save a second Pojo hibernate give me an Exception.

I think that my problem is that the generator id 'incremente' oj my clid class don't work correctly.

Hibernate version: 2.1.6

Mapping documents:
In the side 'one' of de relationship:
<list
name="lnkItemNotaPedido"
lazy="true"
inverse="false"
cascade="all"
>

<key
column="codigoNotaPedido"
>
</key>

<index
column="codigo"
/>

<one-to-many
class="com.grupoBazar.genesis.ventas.notaPedido.ItemNotaPedido"
/>
</list>

In de side 'many' of the relationship
<class
name="com.grupoBazar.genesis.ventas.notaPedido.ItemNotaPedido"
table="ItemNotaPedido"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="codigo"
column="codigo"
type="long"
>
<generator class="increment">
</generator>
</id>

Code between sessionFactory.openSession() and session.close():
public void insertar(Serializable notaPedido){
Session aSession = getSession();
Transaction tx = null;
try {
tx = aSession.beginTransaction();
aSession.save(notaPedido);
tx.commit();
} catch (HibernateException e) {
LOG.error("Ocurrio un error actualizando el objeto: " + (char)operacion, e);
if (tx != null) {
try {
tx.rollback();
} catch (HibernateException e1) {
LOG.fatal("No se pudo hacer rollback de la transacci


Top
 Profile  
 
 Post subject: I have the same problem
PostPosted: Mon Jun 12, 2006 7:11 am 
Newbie

Joined: Mon May 29, 2006 6:07 am
Posts: 12
Do you have a solution? I´ve got the same problem.
Could you show me the solution, please?

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