-->
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.  [ 1 post ] 
Author Message
 Post subject: Delete records from database
PostPosted: Tue May 18, 2010 12:37 am 
Newbie

Joined: Tue May 18, 2010 12:22 am
Posts: 1
Hi All,

In our application I am working on a module wherein we allow user to delete the records from the database. They can select records to delete or just delete everything. The number of records could be more than 500000.

Here is part of the attachment.hbm.xml
Code:
<class name="Attachment" table="attachment">
<id name="Id" type="integer" column="att_id" >
<set name="assignmentassigns" inverse="true" lazy="true" cascade="all,delete-orphan">
   <key column="att_id" foreign-key="FK_assignment_attachment"/>
   <one-to-many class="assignment"/>
</set>


Here is the code in the dao.
Code:
Query query = getSession().createQuery("delete from attachment");
query.executeUpdate();


My question:
1. Is it the right way to delete huge number of records?
2. I get the following exception when I execute the above code.
ERROR org.hibernate.util.JDBCExceptionReporter - The DELETE statement conflicted with the REFERENCE constraint "FK_assignment_attachment". The conflict occurred in database "mydb", table "dbo.assignment", column 'att_id'.

Could anyone guide me in the right path?

Thanks!!


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

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.