-->
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: Why updating when adding to collection?
PostPosted: Mon Nov 01, 2004 2:46 pm 
Newbie

Joined: Fri Oct 29, 2004 9:40 am
Posts: 3
Using Hibernate version 2.1.2, I'm executing the following code:


Session session = this.sessionFactory.openSession();
Transaction tx = session.beginTransaction();

theGroup = (PersistentEnumValueGroup)session.load( PersistentEnumValueGroup.class, new Integer(3) );

PersistentEnumValue theEnumValue = new PersistentEnumValue();
theEnumValue.setGroupId( theGroup.getId() );
theEnumValue.setCode( new Integer(1) );
theGroup.getEnumValues().add( theEnumValue );

theEnumValue = new PersistentEnumValue();
theEnumValue.setGroupId( theGroup.getId() );
theEnumValue.setCode( new Integer(2) );
theGroup.getEnumValues().add( theEnumValue );

session.update( theGroup );

tx.commit();
session.close();


And I get the following output:

13:24:25,139 DEBUG BasicCollectionPersister:567 - Deleting rows of collection: [com.freddiemac.ads.persistence.PersistentEnumValueGroup.enumValues#3]
13:24:25,139 DEBUG BasicCollectionPersister:592 - no rows to delete
13:24:25,139 DEBUG BasicCollectionPersister:732 - Updating rows of collection: com.freddiemac.ads.persistence.PersistentEnumValueGroup.enumValues#3
13:24:25,139 DEBUG BasicCollectionPersister:737 - done updating rows: 0 updated
13:24:25,149 DEBUG BasicCollectionPersister:606 - Inserting rows of collection: [com.freddiemac.ads.persistence.PersistentEnumValueGroup.enumValues#3]
13:24:25,149 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
13:24:25,149 DEBUG SQL:237 - update ENUM_VAL set id_enum_val_grp=? where id_enum_val_grp=? and cd_enum_val=?
13:24:25,149 DEBUG BatcherImpl:241 - preparing statement
13:24:25,149 DEBUG IntegerType:46 - binding '3' to parameter: 1
13:24:25,149 DEBUG Cascades:331 - id unsaved-value strategy NONE
13:24:25,149 DEBUG IntegerType:46 - binding '3' to parameter: 2
13:24:25,159 DEBUG IntegerType:46 - binding '2' to parameter: 3
13:24:25,159 ERROR SessionImpl:2343 - Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)


Why is Hibernate trying to do an update when it should be doing an insert?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 01, 2004 4:57 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
without mapping file, we cannot help you

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.