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.
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
Dave Clark<br />Senior WebSphere Architect<br /><a href="http://www.versant.com" target="_blank" rel="nofollow">Versant Open Access - JDO2 & EJB3</a>