-->
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: many-to-many delete and insert existing rows
PostPosted: Wed Jun 29, 2005 11:27 am 
Newbie

Joined: Wed Oct 20, 2004 6:22 am
Posts: 9
Hello I have a report and a reporter linked by a many-to-many relationship . The table between report and reporter is ext_report_reporters.
Everytime I add a new reporter to my report, hibernate will delete all the previous lines in ext_report_reporters before inserting them again even though it is creating exactly the same row as it has deleted. Anything I could turn off so it doesn't delete and recreate the same row ? This behavious is causing me problems because I have triggers on my ext_report_reporters table in insert
Thanks
Cecile

Hibernate version:
2.1.7

Code between sessionFactory.openSession() and session.close():
ReportAbstract report = new Report();
report.addReporter(getNewReporter());

tx = session.beginTransaction();
reportDAO.saveOrUpdateReport(report);
tx.commit();

assertNotNull("New report added",report.getReportId());

report.addReporter(createReporter());

tx = session.beginTransaction();
reportDAO.saveOrUpdateReport(report);
tx.commit();
Name and version of the database you are using:
oracle 9i
The generated SQL (show_sql=true):
Hibernate: select SQ_EXT_REPORTER_ID.nextval from dual
Hibernate: insert into EXT_REPORTER (OCCUPATION_CODE, ANCILLARY_DOCUMENTS_FLAG, ANCILLARY_DOCUMENT, OCCUPATION_OTHER, REPORTER_TYPE_CODE, REPORTER_SOURCE_CODE, NOTIFICATION_CODE, SPECIALITY_CODE, LAST_NAME, FIRST_NAME, ORGANISATION_NAME, LOCATION, ADDRESS_LINE1, ADDRESS_LINE2, ADDRESS_LINE3, ADDRESS_LINE4, CITY, POSTAL_CODE, COUNTRY_CODE, REGION_CODE, EMAIL_ADDRESS, FAX_NUM, PHONE_NUM, PRIMARY_REPORTER, REPORTER_DISCRIMINATOR, REPORTER_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'R', ?)
Hibernate: delete from EXT_REPORT_REPORTERS where REPORT_ID=?
Hibernate: insert into EXT_REPORT_REPORTERS (REPORT_ID, REPORTER_ID) values (?, ?)
Hibernate: insert into EXT_REPORT_REPORTERS (REPORT_ID, REPORTER_ID) values (?, ?)
Hibernate: insert into EXT_REPORT_REPORTERS (REPORT_ID, REPORTER_ID) values (?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 30, 2005 4:58 am 
Newbie

Joined: Wed Oct 20, 2004 6:22 am
Posts: 9
Acutally I just realised that what Hibernate does is to delete everything in that table for that report before inserting again the old records and the new record as well.... I am very puzzle here. Any flag to set somewhere or a property to set so it doesn't delete...
ANy help would be very appreciated .
Cecile


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.