File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "view - javabeans - dao" Watch "view - javabeans - dao" New topic

view - javabeans - dao

Samuel Cox
Ranch Hand

Joined: Nov 16, 2004
Posts: 96


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

good luck,


Dave Clark<br />Senior WebSphere Architect<br /><a href="" 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.
I agree. Here's the link:
subject: view - javabeans - dao
It's not a secret anymore!