You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/06/03 08:10:01 UTC

Re: Design Advice - Relational Databases & Java Objects

Subject: Re: Design Advice - Relational Databases & Java Objects
From: Vic C <vi...@basebeans.com>
 ===
Somone someplace need to know "how" the DB layer talks to DB. No magic 
in computers, and a common applied practice is roll your own beans.

The beans need to logicaly map to the presentation. For example if you 
have a master detail or more complex relationship on the page, I do this 
using beans that contains beans that iterate that reprsent the logical 
relationship (for example a mutual fund information with a list of 
stocks in it would be a mortgage bean that has a DAO that contains a 
stock bean that iterates and has a stocks DAO based on a foreign key, if 
that is what the user wants to see). But how this logical relationship 
makes sense in your application requires your thinking, therefore no O/R 
tool can do it for you.

In addition, you need to make sure your beans work with other tags, such 
as Standard Tags (you should be using Standard Tags as much as possible) 
or even bean define. Implication here is that if you have MVC simple 
beans you are set. However if you do PetStore type designs, where you 
have BO and VO and DTO... it makes it a bit less flexible.

Most automated tools are only usefull for very simple or very small 
applications.
Just learn JDBC and RowSet and you are set.

my 2 c.
Vic




Jin Bal wrote:
> IMHO
> It's better that any db access layer does not know "how" to get a database
> connection,  it just gets given them by the client calling it.  This way if
> you need to change the way you grab db connections the db access layer is
> none the wiser and no code changes are needed
> 
> Jin
> ----- Original Message -----
> From: "Adam Hardy" <ad...@cyberspaceroad.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, May 29, 2002 5:44 PM
> Subject: Design Advice - Relational Databases & Java Objects
> 
> 
> 
>>Hi All,
>>
>>I saw this thread in the archives and I thought I'd pinch the title.
>>I've spent this afternoon surfing the web looking at stuff on Sun,
>>Jakarta  and lots of smaller sites looking for a ready-made data access
>>layer package but I take it there isn't an open-source one out there.
>>
>>Obviously I don't want to tie my data access layer to struts, so there
>>are a few questions I've got.
>>
>>(1) Is it best for the data access layer to throw exceptions on error to
>>be picked up by the business objects & then struts actions, or would it
>>be good to use a struts-type message object and use strings in the
>>application resources file (I'm just worried my exceptions' text would
>>not be multi-lingual)
>>
>>(2) How would I get the database connection info to the data access
>>layer? Presuming I want to set it up in struts-config.xml or as in
>>commons-dbcp, would I then pass it in from struts actions into the
>>business object and then into the data access layer as a parameter on
>>each call?
>>
>>
>>
>>I've seen quite a few patterns like www.martinfowler.com and code like
>>in Sun's Pet Store, so I think I've got a fairly good idea of what I
>>need. The data access layer I want has got to:
>>
>>- take as input and return as output Data Transport Objects
>>- allow the business objects to control transactions
>>- use a connection pool
>>- possibly keep the SQL statements in an external XML file
>>- have comprehensive error handling & reporting
>>
>>
>>
>>
>>--
>>To unsubscribe, e-mail:
> 
> <ma...@jakarta.apache.org>
> 
>>For additional commands, e-mail:
> 
> <ma...@jakarta.apache.org>
> 
>>
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>