DAO

Hi friends.

I want use DAO for create a Swing application, that acess to PostgreSQL.

I want to retrieve a list of objects ( for example: clients), How is the best implementation?

Client[] clients = ClientDAO.getClients();

or

javax.sql.RowSet clients = ClientDAO.getClients();

I'll use result ('clients') to show in a JTable;

Another question, if i only want a chunk of clients (first 10, after another 10, ..), how can i implement this?.

Last question, Is there some utility to facilitate the work with DAO?

Thank you, very much.

[594 byte] By [TechGSisa] at [2007-11-27 9:09:16]
# 1
Never, ever pass your result set out of your DAO.The first is what you should do.
darteda at 2007-7-12 21:48:59 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

> Never, ever pass your result set out of your DAO.

> The first is what you should do.

Exactly. The point of the pattern is to shield client code from details of the datastore, such as the fact that there's a JDBC resultset involved. Whenever considering adding a layer to your app, first ask what actual value it will add, don't just do it because it seems the done thing

georgemca at 2007-7-12 21:48:59 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

> Another question, if i only want a chunk of clients

> (first 10, after another 10, ..), how can i implement

> this?.

>

Ideally using a sequential primary key.

Other than that the solutions become harder and are data dependent.

> Last question, Is there some utility to facilitate

> the work with DAO?

Code generation is how I do it.

jschella at 2007-7-12 21:48:59 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
Thank you, for your help.
TechGSisa at 2007-7-12 21:48:59 > top of Java-index,Other Topics,Patterns & OO Design...