-->
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.  [ 5 posts ] 
Author Message
 Post subject: Modifying the objects in collection
PostPosted: Fri Mar 26, 2004 12:30 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
Hello,

When I get the set from the persistent object the set has say 3 objects with ids 1,2,3. Now if I modify the collection and select only one of them say 2 it should reflect the database right ? I read the One Shot Delete and following the same method.

HashSet hs = PO.getAphasiaSet();
hs.clear(); // Clearing the old values
hs.add(dao.getAphasia(2)); // Adding new value
PO.setAphasiaSet(hs);
save(PO);

waiting for replies,


nitin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 12:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
"one shot delete" does not apply to one-to-many associations, only many-to-many and collections of values


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 12:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You need cascade="all-delete-orphan".


Top
 Profile  
 
 Post subject: Still facing the same problem
PostPosted: Fri Mar 26, 2004 1:02 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
Thanx gavin,

I am still getting these exceptions.. And I cannot see a single delete query being fired on database.

Hibernate: update STS.METADATA_SUBJECT_APHASIA set SUBJECT_ID=null where SUBJECT_ID=? and ID=?
WARN [http8080-Processor2] JDBCExceptionReporter.logExceptions(38) | SQL Error: 1407, SQLState: 72000
ERROR [http8080-Processor2] JDBCExceptionReporter.logExceptions(46) | ORA-01407: cannot update ("STS"."METADATA_SUBJECT_APHASI
A"."SUBJECT_ID") to NULL

WARN [http8080-Processor2] JDBCExceptionReporter.logExceptions(38) | SQL Error: 1407, SQLState: 72000
ERROR [http8080-Processor2] JDBCExceptionReporter.logExceptions(46) | ORA-01407: cannot update ("STS"."METADATA_SUBJECT_APHASI
A"."SUBJECT_ID") to NULL

ERROR [http8080-Processor2] JDBCException.<init>(38) | Could not execute JDBC batch update
java.sql.SQLException: ORA-01407: cannot update ("STS"."METADATA_SUBJECT_APHASIA"."SUBJECT_ID") to NULL
.
.
.
ERROR [http8080-Processor2] SessionImpl.execute(2343) | Could not synchronize database state with session
net.sf.hibernate.JDBCException: Could not execute JDBC batch update


nitin


Top
 Profile  
 
 Post subject: Set tag
PostPosted: Fri Mar 26, 2004 1:10 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
My set tag looks like this ..

<set name="aphasiaTypes" cascade="all-delete-orphan">
<key column="SUBJECT_ID"/>
<one-to-many class="com.imc.sts.domain.the.SubjectAphasia" />
</set>

nitin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.