-->
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.  [ 5 posts ] 
Author Message
 Post subject: Is there a way to evict associated collection?
PostPosted: Mon Jul 26, 2004 10:50 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 12:28 pm
Posts: 27
Location: New York
there is a method in SessionImplementor, but no such thing in Session?
Is there another way of doing it in Hibernate without actually going thru Hibernate's internal APIs?

_________________
Thanks,
Alex


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 10:51 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You evict() regions, not "collections". A region can be a collection role or an entity role, or whatever granularity you have given your regions.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 10:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
What do you mean by "evict"?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 10:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Uhm, I think he means evict() on the Session, not the second-level cache... So, the answer would be "no".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 11:05 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 12:28 pm
Posts: 27
Location: New York
Quote:
What do you mean by "evict"?


suppose I have an Applicant class that has a one-to-many association to Education class. Let's say education set is not lazy.

Applicant {
...
Set education;
...
}

I retrieve an Applicant and send it over to the web tier. Web tier creates an Education record and sends it back to the business tier for save.
Code:
addEducation (Applicant a, Education e) {
  -- open new session
  -- lock applicant record
  if (a.getEducation ().size () >= 2) {
    trhow exception (too many education recs)
  } else {
    a.getEducation ().add (e);
  }

  s.saveOrUpdate(a);
}


as you can imagine the code above will be problematic if database is accessed from multiple applications (and in my case it is). So while web tier was adding education record some administartor might add education record and my business rule will fail (the one that says no more than two records allowed). Hence was my question what do I do to evict not the whole applicant record but just a collection it is associated with?


[/quote]

_________________
Thanks,
Alex


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