-->
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: collection updating strategy
PostPosted: Tue Aug 07, 2007 12:48 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 10:51 pm
Posts: 29
Location: sydney australia
Hibernate version: 8.1.3

Hi all,

I've got a situation where I need to retrieve a list of persistent objects (which happen to use a composite primary key), remove some elements, update others, change unique/primary keys and then save it. I'd to have all inserts, updates and deletes within the scope of a transaction.

so basically
1. begin transaction
2. return list from query
3. delete one entry
4. update a non pk field on another
5. update a pk field on another
6. insert a new element with unique pk fields
7. save
8. commit transaction

it seems no matter what i try, i always get a warning in my log files:
WARN org.hibernate.cache.ReadWriteCache - An item was expired by the cache while it was locked (increase your cache timeout)

I'm using a composite key consisting of a string (groups elements by user) and a start date (unique for each user).

so basically an example could start with the following:
user: 1, start date: 01/02/2007, values: a
user: 1, start date: 02/02/2007, values: b
user: 1, start date: 03/02/2007, values: c
user: 1, start date: 04/02/2007, values: d

and end with the following:
user: 1, start date: 01/02/2007, values: a
user: 1, start date: 02/02/2007, values: c
user: 1, start date: 05/02/2007, values: d

or:
user: 1, start date: 01/02/2007, values: a
user: 1, start date: 05/02/2007, values: b
user: 1, start date: 06/02/2007, values: c
user: 1, start date: 07/02/2007, values: d

or:
user: 1, start date: 01/02/2007, values: a
user: 1, start date: 03/02/2007, values: c
user: 1, start date: 05/02/2007, values: b
user: 1, start date: 06/02/2007, values: c
user: 1, start date: 07/02/2007, values: d

if i were outside of hibernate it would be pretty simple; just a case of deleting all elements using the same where clause as the original query then inserting the elements now in the list.

PLEASE HELP!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 3:31 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 10:51 pm
Posts: 29
Location: sydney australia
never mind. i fixed it.

just making sure never to change the primary key. if i need to i delete and instert instead.


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.