This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes view - javabeans - dao Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "view - javabeans - dao" Watch "view - javabeans - dao" New topic
Author

view - javabeans - dao

Samuel Cox
Ranch Hand

Joined: Nov 16, 2004
Posts: 96

Hi,

First, let me apologize if this is the wrong forum.

Like many beginner J2EE - MVC programmers, I am trying to move business logic currently incorporated in the view and controller layer to the model layer. I am planning on implementing a Struts <-> JavaBean <-> DAO approach. However, I'm unsure as to how to uniquely represent my JavaBean objects that come from DAOs. I'm assuming that my DAO should contain the primary key values which allow easy database access. Should these values be carried through to the JavaBean in the middle? Similarly, should the view be requesting items by the primary keys taken from the database or is this considered bad design?

If anyone has any tips or links to websites with tips/examples for this type of solution, I would be very thankful if you'd share.
Dave Clark
Ranch Hand

Joined: Feb 16, 2005
Posts: 52
Hi Samuel,

you'll save yourself a lot of coding and maintenance if you just write your Java objects to model your domain model, map these Java objects to your DB schema with JDO (Java Data Objects), and then simply store and retrieve these Java objects via the JDO PersistenceManager. That way you can write your queries in either JDOQL or SQL, and you **don't need to hand-code a set of DAO's**.

JDO also gives you the option of datastore identity (ID's generated by the JDO persistence impementation) or Application ID's which you can generate and access directly in your code. Which approach is right depends on your app.

Some good JDO implementations - open source and commercial - can be found at jdocentral.com

good luck,

Dave


Dave Clark<br />Senior WebSphere Architect<br /><a href="http://www.versant.com" target="_blank" rel="nofollow">Versant Open Access - JDO2 & EJB3</a>
Samuel Cox
Ranch Hand

Joined: Nov 16, 2004
Posts: 96

Thanks for the tips.

I'll investigate JDO.
 
jQuery in Action, 2nd edition
 
subject: view - javabeans - dao
 
Similar Threads
Spring DAO: When and Where to catch/throw exceptions
selecting a value in drop down box
Using JavaBean with Java classes, JSP and MS Access
Preventing access of DAO layer from Service layer.
DAO and Entity class