Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
DAO relation with business object

DAO relation with business object

2004-06-22       - By Soumen Saha

 Back
Reply:     1     2     3     4     5  

Hi Wim,
   The best way to diffrentiate is to understand that Business Objects
reflect the Object Model of your system. It should not
be what your database object look like and neither what the UI want. for UI,
you need to use Value Objects.
So your dataaccess layers returns a Business Object or a hierarchy of
Business Objects to the Business Layer. which in turn
does required business rule implementation and returns the modified
BusinessObject to the UI Layer. The UI helpers convert
the Business Object to Value Object for UI display purposes

2nd Problem:
Your DAO is part of the dataAccess Layer so it should return a
BusinessObject.

So public User getUser(int id); should be your signature.

- Somu.


-- -- Original Message -- --
From: "Sullivan, Sean C - MWT" <Sullivan.Sean@(protected)>
To: <J2EEPATTERNS-INTEREST@(protected)>
Sent: Monday, June 21, 2004 9:34 PM
Subject: Re: DAO relation with business object


These resources may be helpful:

http://corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm

http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObjec
t.html

http://daoexamples.sourceforge.net/related.html

http://www-106 (See http://www-106.ora-code.com).ibm.com/developerworks/java/library/j-dao/


-- --Original Message-- --
From: An interest list for Sun Java Center J2EE Pattern Catalog
[mailto:J2EEPATTERNS-INTEREST@(protected)] On Behalf Of Deblauwe, Wim
Sent: Monday, June 21, 2004 8:09 AM
To: J2EEPATTERNS-INTEREST@(protected)
Subject: DAO relation with business object


I've looking at the DAO pattern lately and have some problems with it.
Especially what is ment by Business Object and ValueObject?

In my words I would call a class User that is a POJO a Business Object,
and I would place it in a package "business".

I would then have a class ValueUser in my data package that has all the
same methods as business.User. In fact, business.User is just a delegate
to data.ValueUser.

Is this already correct? Or is the business class something else and is
my User class already a ValueObject?

2nd problem:
When I then create my DAO, e.g. UserDAO. This would typically reside in
the data package. There are 2 options then:

public User getUser(int id);

or

public ValueUser getUser(id);

If my business.User class is already a ValueObject, then a class from my
data-layer is dependant on a class from my business-layer. This would be
undesirable I think.
Otherwise we refer to the ValueUser which is in the same layer, so this
seems ok. But when you try to unit-test User when it is just a delegate
for ValueUser, you will do this:

ValueUser valueUser = new ValueUser();
valueUser.setName( "testName" );
... some more here

User user = new User();
user.setValueObject( valueUser );

assertEquals( user.getName(), "testName" );

And I really don't like this. You have to create 2 objects, where 1
should be enough.

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
listserv@(protected)

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.