Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Best way to map Javabean to RDMS?

Reply
Thread Tools

Best way to map Javabean to RDMS?

 
 
Marc Twain
Guest
Posts: n/a
 
      11-21-2003
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
 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      11-21-2003
Marc Twain wrote:
> 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/corej...essObject.html
http://www.hibernate.org/


 
Reply With Quote
 
 
 
 
Gerbrand van Dieijen
Guest
Posts: n/a
 
      11-22-2003
On Fri, 21 Nov 2003 17:54:13 +0100, Michael Borgwardt wrote:
>Marc Twain wrote:
>> 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".
>


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.

--
Gerbrand van Dieijen

 
Reply With Quote
 
quentincompson
Guest
Posts: n/a
 
      11-24-2003
"Michael Borgwardt" <(E-Mail Removed)> wrote in message
news:bplfvr$1pcthl$(E-Mail Removed)-berlin.de...
> Marc Twain wrote:
> > 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/corej...ccessObject.ht
ml
> http://www.hibernate.org/
>
>


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?






 
Reply With Quote
 
Michael Borgwardt
Guest
Posts: n/a
 
      11-24-2003
quentincompson wrote:
> 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.

 
Reply With Quote
 
quentincompson
Guest
Posts: n/a
 
      11-24-2003
"Michael Borgwardt" <(E-Mail Removed)> wrote in message
news:bpt9h6$1s027f$(E-Mail Removed)-berlin.de...
> quentincompson wrote:
> > 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.


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.



 
Reply With Quote
 
Michael Borgwardt
Guest
Posts: n/a
 
      11-24-2003
quentincompson wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javabean referencing Application variables Todd Peterson Java 2 09-11-2003 10:39 PM
Creating a page-level ErrorBuffer JavaBean Andy Java 0 07-30-2003 10:26 AM
Re: Use one javabean for each table? tom Java 0 07-24-2003 09:20 PM
Re: Use one javabean for each table? A Bag Of Memes Java 0 07-24-2003 05:45 AM
Missing JavaBean.. Andrew Thompson Java 4 07-07-2003 07:34 PM



Advertisments