Best way to map Javabean to RDMS?

M

Marc Twain

I'm surprised how little material there is available on the web
regarding the creation of objects based on data from an RDBMS.

For the simple things, like say Employee objects, I : 1) create an
employee class 2) in a 'EmployeeDB' bean, add a 'getEmployee' and
'addEmployee' method to interact with the db (populating or receiving
an instance of the 'Employee' class.

Now for the more complex stuff I must admit I could really use some
simple pointers. For example if I want to retreive a collection of
employee, should I make the 'getEmployees' method a part of the
EmployeeDB bean or should I create a brand new Class called
'EmployeeCollection'? Not to mention that I have no idea what to put
in the constructor of my EmployeeDB bean.

Any pointers? (url, etc?)

TIA,

AJ
 
M

Michael Borgwardt

Marc said:
I'm surprised how little material there is available on the web
regarding the creation of objects based on data from an RDBMS.

Then you haven't been looking properly. The term you should be looking
for is "Object-relational (or O/R) Mapper".
Now for the more complex stuff I must admit I could really use some
simple pointers. For example if I want to retreive a collection of
employee, should I make the 'getEmployees' method a part of the
EmployeeDB bean
Yes.

Any pointers? (url, etc?)

http://java.sun.com/products/jdo/
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
http://www.hibernate.org/
 
G

Gerbrand van Dieijen

Then you haven't been looking properly. The term you should be looking
for is "Object-relational (or O/R) Mapper".

I certainly agree with that. I struggled with similar problems too a long
time, creating my own get ... classes for retrieving data from the
database. I know use JDO which is by far more easier and better to use.

I won't say JDO is the best for persistency, but it's a lot better then
jdbc and developing you're own persistency classes.
 
M

Michael Borgwardt

quentincompson said:
what's the difference between an implementation of the DAO pattern and
something like Castor or JDO? are castor & jdo simply implementations of the
DAO pattern?

Basically yes, though it would be more correct to say that they *generate*
code that implements a specific variant of the DAO pattern.
 
Q

quentincompson

Michael Borgwardt said:
Basically yes, though it would be more correct to say that they *generate*
code that implements a specific variant of the DAO pattern.

ok, its beginning to make sense. thanks.

do you know of a place where i can download a simple implementation of the
DAO pattern. castor is a little complex for just starting out. my goal is
to write a simple dao implementation and learn how it works...

tia.
 
M

Michael Borgwardt

quentincompson said:
do you know of a place where i can download a simple implementation of the
DAO pattern. castor is a little complex for just starting out. my goal is
to write a simple dao implementation and learn how it works...

Not sure, but the J2EE Pet Store Sample Application at
http://java.sun.com/blueprints/code/
may contain a good example in its package
com.sun.j2ee.blueprints.catalog.dao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top