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: Business rules: in the model or in DAO?
PostPosted: Tue May 10, 2005 1:37 pm 
Newbie

Joined: Wed Oct 06, 2004 4:39 pm
Posts: 17
Hi,

I have a doubt on like implementing a business rule.

My use case need retrieve purchase orders that can be modified. The business rule say that a order can be modified if it is opened and his items have pending delivery.

I can include a method in the PurchaseOrder's DAO and use HQL to retrieve the orders that satisfy the conditions. But I think that of this one form the rule remains hide and is not a part of the domain model.

Which is the best way of implementing rules of this style?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 1:50 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
The impression I got after reading Hibernate in Action is that it is best to keep business logic in the model and try to limit the DAOs to persistence concerns. The flow kind of went like this:

1. Load something from the DAOs
2. Pass result to business object method(s)
3. Get result(s) from business object method(s)
4. Pass result to DAOs

However, for performance reasons it makes sense to execute the logic in HQL, as the database is much more efficient at queries. What you could do is create a DAO method called getOpenOrdersWithPendingItems( ) that executes the HQL you mentioned. Although you are implementing logic in the query, you are not hiding it because the method does exactly what it says and it's not tied to a use case. A bad name would be getModifiableOrders( ), since that doesn't tell you what kind of selection criteria is being imposed and does tie itself to a use case.

- Jesse


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.