One table One Dao is the best practise?????

Discussion in 'Java' started by lightning, Jul 7, 2008.

  1. lightning

    lightning Guest

    Many articles seem to told us that one table one dao is just fine and
    hibernate are enough to do the business.

    I also see the thread 'DAO patterns in the "Real World"' in this group
    but I still don't get the answer.The author of the thread indeedly
    give out a very good question but at last there are no solutions good
    enough for that question.

    In real world,logic can be much more complicated than which in the
    tutorial,and performance is important,too.

    Hibernate can deal with 1:n,n:m mapping,but that is very simple in the
    real word, and in

    In real project, may I wanna show some data in one table ,but which
    row to be shown is decided by other tables.

    use SQL,I can just select many ids from many different tables and at
    last use a "where id in ..." to query some fieds in a table that I
    need to show.

    If Using DAO:
    1, where should I put the SQL in?
    2, Using hibernate, need I create one PO for every view?
    3, If we really use DAO and hibernate to deal with this, how much
    memory and cpu cycles would be wasted?


    The key of the question is - what is the best practice of using dao in
    the project to solve complex query or complex update??
     
    lightning, Jul 7, 2008
    #1
    1. Advertising

  2. lightning

    EricF Guest

    In article <>, lightning <> wrote:
    >Many articles seem to told us that one table one dao is just fine and
    >hibernate are enough to do the business.
    >
    >I also see the thread 'DAO patterns in the "Real World"' in this group
    >but I still don't get the answer.The author of the thread indeedly
    >give out a very good question but at last there are no solutions good
    >enough for that question.
    >
    >In real world,logic can be much more complicated than which in the
    >tutorial,and performance is important,too.
    >
    >Hibernate can deal with 1:n,n:m mapping,but that is very simple in the
    >real word, and in
    >
    >In real project, may I wanna show some data in one table ,but which
    >row to be shown is decided by other tables.
    >
    > use SQL,I can just select many ids from many different tables and at
    >last use a "where id in ..." to query some fieds in a table that I
    >need to show.
    >
    >If Using DAO:
    >1, where should I put the SQL in?
    >2, Using hibernate, need I create one PO for every view?
    >3, If we really use DAO and hibernate to deal with this, how much
    >memory and cpu cycles would be wasted?
    >
    >
    >The key of the question is - what is the best practice of using dao in
    >the project to solve complex query or complex update??
    >

    1)A DAO is a data access object. The SQL - if you need SQL - goes there. In
    many cases you won't need SQL if using Hibernate.
    2)You probably want a persistent object for each view, but that's not
    necessarily the case. Can 1 PO be used for several views? I don't know you
    application.
    3)Hibernate does a better job of generating SQL than many developers. You may
    save cycles, maybe you won't. Do a trial and see what you thing.

    Try Google for best practices.

    Eric
     
    EricF, Jul 8, 2008
    #2
    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. exquisitus
    Replies:
    0
    Views:
    491
    exquisitus
    Feb 20, 2005
  2. VisionSet
    Replies:
    0
    Views:
    846
    VisionSet
    Aug 19, 2003
  3. Rich

    Architecture best practise

    Rich, Jun 30, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    518
    Nick Malik [Microsoft]
    Jul 11, 2006
  4. Mat

    Video file - best practise

    Mat, Aug 14, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    352
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 14, 2006
  5. GW

    Best Practise

    GW, Nov 17, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    412
Loading...

Share This Page