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: How to avoid dependency on Hibernate in business objects
PostPosted: Thu Dec 23, 2004 4:17 am 
Newbie

Joined: Thu Nov 04, 2004 10:24 am
Posts: 17
Some methods in my business objects must load data through queries rather than direct Hibernate-mapping.

E.g., a
Code:
Department
class has methods
Code:
getEmployees()
and
Code:
getSalary()
which are mapped to the DB using Hibernate.

There is another method
Code:
getHighSalariedEmployees()
which returns employees with salaries greater than 100,000. I can execute an HQL query inside getHighSalariedEmployees() .

But I don't want query-definition and -execution code inside my business object Department.

Suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 4:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
There is another method getHighSalariedEmployees()
which returns employees with salaries greater than 100,000. I can execute an HQL query inside getHighSalariedEmployees() .

But I don't want query-definition and -execution code inside my business object Department.

Suggestions?


MVC / DAO mismatch
you can access data layer from your domain model but everyone will advise you not to do it for a lot of good reasons.

3 solutions with Hibernate 2:
- let hibernate retrieve the full list and lets filter it in java (not really performant depending on list size)
- map a second collection with a "where saliaries > 100000" clause
- just let the controller do this stuff, it's exactly what it should do

2 bests solutions with hibernate 3:
- use dynamic filter
- use lazy formula property
these two features are EXCELLENT and solve the data access problems

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 8:55 am 
Newbie

Joined: Tue Dec 21, 2004 10:53 am
Posts: 8
Location: Stuttgart/Germany
Yes, but then H3 must be available


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 9:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
again:
- just let the controller do this stuff, it's exactly what it should do

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 1:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
chainsaw wrote:
Yes, but then H3 must be available

H3 is due to Q1 2005 and is ready for development

_________________
Emmanuel


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.