-->
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.  [ 7 posts ] 
Author Message
 Post subject: How would y'all model this?
PostPosted: Mon Sep 20, 2004 9:46 pm 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
I've got some persistent Objects, duh. After each update, if the Object's data values are not valid, a set of Problem objects are created and attached to the Object. All well and good, but here's the little twist. For various reasons, the Problem objects must not be deleted when resolved, but rather simply closed. However, in my application code, it is very seldom that I am interested in any but the open Problems, so it seems silly to always be iterating over the Problems and continuing on closed Problems.

I can easily use hibernate filters on the problems collection to efficiently skip closed problems, but then I've got hibernate-specific code hanging out in my business logic where ideally it would not belong. I've idly thought about giving my Objects two Problem collections, one for open, one for closed, and just move the Problems from one to the other when they're resolved. Would that be the best way to do it or is there another design pattern you might recommend?

Cheers, y'all.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 2:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what about advanced hql or collection filter ?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 11:25 am 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
Sure, either of those is quite effective, but the problem is that it embeds some hibernate-specific stuff in my business logic. I want to avoid that to the greatest extent possible. I almost exclusively traverse the object graph in my business logic.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 11:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
isolate this into a DAO or helper layer interface


do this can help?:

Quote:
where="arbitrary sql where condition" (9)


http://www.hibernate.org/hib_docs/refer ... tions.html

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 2:30 pm 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
Thanks for the tips. I myself don't really like the DAO pattern and am not using it on this project. The arbitrary where clause would be a way to do it if it were possible to have hibernate map two collections with different where clauses under the same parent.

I think I'll probably end up just mapping two different collections with different association tables for open and closed problems.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 24, 2004 1:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You could do this easily in Hibernate3 with its new dynamic filter stuff.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 24, 2004 11:03 am 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
Cool. I look forward to checking it out.


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