If you are using a relational database instead of an object databse, ideally you would want to use a persistence engine that maps each db table row to a
java object. This object to relational mapping would allow you to just work with objects.
Scott Ambler has some good white papers on his website
http://www.ambysoft.com/ and the two articles of interest are:
Mapping Objects to Relational Databases: What You Need to Know and Why
http://www-106.ibm.com/developerworks/library/mapping-to-rdb/ Tips for Mapping Objects to Relational Databases
http://www.ambysoft.com/mappingObjects.html Here is the first paragraph in his article at the ibm website that I feel is relevant to the topic of this discussion.
Why a paper about mapping objects to relational databases? Because of the "impedance mismatch" between the object paradigm and the relational paradigm. The object paradigm is based on software engineering principles such as coupling, cohesion, and encapsulation, whereas the relational paradigm is based on mathematical principles, particularly those of set theory. The two different theoretical foundations lead to different strengths and weaknesses. Furthermore, the object paradigm is focused on building applications out of objects that have both data and behavior, whereas the relational paradigm is focused on storing data. The "impedance mismatch" comes into play when you look at the preferred approach to access: with the object paradigm you traverse objects via their relationships, whereas with the relational paradigm you duplicate data to join the rows in tables. This fundamental difference results in a less-than-ideal combination of the two paradigms, but then, a few hitches are to be expected. One of the secrets of success for mapping objects to relational databases is to understand both paradigms and their differences, and then make intelligent trade-offs based on that knowledge.
A couple of open source object-relational persistence engines are:
http://osage.sourceforge.net/ and
http://castor.exolab.org/ A couple of commercial OR mapping tools are:
CocoBase - an OR mapping tool by Thought Inc.
http://www.thoughtinc.com/cber_index.html Webgain Toplink OR mapping by Webgain
http://www.webgain.com/Products/toplink/toplink_Overview.html Eddy