-->
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.  [ 6 posts ] 
Author Message
 Post subject: update/delete order in batch?
PostPosted: Tue Feb 21, 2006 2:35 am 
Regular
Regular

Joined: Wed Oct 15, 2003 4:40 pm
Posts: 67
Is there a way to force deletes to happen before updates when Hibernates executes its queries?

I remove a detail row from a collection in a standard master-detail relationship and then renumber the index column (a list) to patch up the hole but when I flush the parent the updates are done before the delete and I hit a unique-check violation in the DB.

Can this be done by configuration or do I have to delete the detail row explicitly?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 12:07 pm 
Newbie

Joined: Tue Feb 21, 2006 10:31 am
Posts: 7
I don't know if I understood well but if you have, for example:

STUDENT ----> READBOOKS where STUDENT is your master and READBOOKS is your "detail" you can simply remove the ReadBook persister from your Set and then update the parent.

Why you need to update your index? To trace the number of books read by the student?

I suppose the relationship between the two entities is one to many

hope that helps


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 4:09 pm 
Regular
Regular

Joined: Wed Oct 15, 2003 4:40 pm
Posts: 67
xlucax wrote:
Why you need to update your index? To trace the number of books read by the student?


Because it is a list and there will be a null row next time it is loaded if there is a gap in the index numbering.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 6:35 am 
Newbie

Joined: Tue Feb 21, 2006 10:31 am
Posts: 7
Do you really need a list? Or you can use Set? If you need ordering feature you can use a SortedSet.
Post some code if you can.

LUCA


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 7:41 am 
Regular
Regular

Joined: Wed Oct 15, 2003 4:40 pm
Posts: 67
xlucax wrote:
Do you really need a list?


For all practical purposes, yes. I do removal of rows from the details while they are only in the presentation layer so I have to access them before they have any meaningful identity.

It would be hard to do(?) if I can't access them in an List-like indexed way like order.getOrderRows().remove(selIndex)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 7:57 am 
Newbie

Joined: Tue Feb 21, 2006 10:31 am
Posts: 7
if you have something like:

ORDER ---> DETAILS I think you could do like that:

imagine you have in the presentation layer lines of DETAILS that you can check/uncheck with checkboxes that have, as values, the DETAILID.

In your controller (if using MVC/MODEL2) you can:

1) take all the IDS selected
2) build a detailPersistersSet with the selected IDS
3) do something like

Set orderDetailsSet = order.getOrderDeatilsSet();
orderDetailSet.removeAll(detailPersistersSet);

4) update the order object

in that way you could use Set for your details obtaining what you want (if I understood well)

hope taht helps


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