Best way to map Javabean to RDMS?

Discussion in 'Java' started by Marc Twain, Nov 21, 2003.

  1. Marc Twain

    Marc Twain Guest

    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
     
    Marc Twain, Nov 21, 2003
    #1
    1. Advertising

  2. 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/corej2eepatterns/Patterns/DataAccessObject.html
    http://www.hibernate.org/
     
    Michael Borgwardt, Nov 21, 2003
    #2
    1. Advertising

  3. 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
     
    Gerbrand van Dieijen, Nov 22, 2003
    #3
  4. "Michael Borgwardt" <> wrote in message
    news:bplfvr$1pcthl$-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/corej2eepatterns/Patterns/DataAccessObject.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?
     
    quentincompson, Nov 24, 2003
    #4
  5. 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.
     
    Michael Borgwardt, Nov 24, 2003
    #5
  6. "Michael Borgwardt" <> wrote in message
    news:bpt9h6$1s027f$-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.
     
    quentincompson, Nov 24, 2003
    #6
  7. 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
     
    Michael Borgwardt, Nov 24, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Thompson

    Missing JavaBean..

    Andrew Thompson, Jul 7, 2003, in forum: Java
    Replies:
    4
    Views:
    446
    Wendy S
    Jul 7, 2003
  2. A Bag Of Memes

    Re: Use one javabean for each table?

    A Bag Of Memes, Jul 24, 2003, in forum: Java
    Replies:
    0
    Views:
    452
    A Bag Of Memes
    Jul 24, 2003
  3. tom
    Replies:
    0
    Views:
    380
  4. Andy
    Replies:
    0
    Views:
    306
  5. Todd Peterson
    Replies:
    2
    Views:
    513
    Todd Peterson
    Sep 11, 2003
Loading...

Share This Page