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: general problems with Hibernate architecture - please advise
PostPosted: Mon Jul 24, 2006 2:31 pm 
Newbie

Joined: Mon Jul 24, 2006 1:35 pm
Posts: 10
Hi,

I've been working on a project involving Hibernate for almost a year now, and the more complex the project gets, the more issues arise. So I wanted to ask for some advice before the situation becomes unbearable.

The main problem I'm facing is a collision between using criteria/filters and doing updates/inserts on detached objects. It looks like when performing criteria searches on the same object (same pk) twice within single session (without clearing the session), just with different filter parameters, cached results from the first search are returned again when the second search is performed. I tried to avoid that by using HQL to find the matching objects, and then calling session.load(pk) to get an object containing those matches, but that approach does not seem to work when lazy loading is enabled (the returned object always contains full object state, regardless of the subset returned by HQL query).
So I changed the code to clear the session, so all search methods would always start with clean slate. That fixed the search problems, but it broke the updates/inserts.
I have many situations where I use a search method to locate an object (which clears session), then I call another search method, and another, and each of them clears the session. Then I try to set the data from all those calls on the first object, and update it.
So in that scenario I started to get exceptions like non unique object and duplicate collections found, and my code stopped working again.

So I'd like to find out if anyone has had to work with similar scenario, and how did you solve those problems? I tried using session.merge instead of session.saveOrUpdate, but then I started getting TransientObjectExceptions and such.

Is there a way out of this dilemma? Is it better to clear the session, and deal with duplicate objects and such, or is it better to maintain the session and find a solution for search criteria issues?
Thanks,

Bratek


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.