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

L

lightning

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??
 
E

EricF

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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top