I wasn't trying to push an ORM view on your approach, with which I quite agree :-)
Also, in this contexts, I'm not interested in traditional JavaBeans.

My only concern is that empire-db's API for querying seems a bit disconnected from the API for writing, and that operations that are simple for a single record become significantly (and in my opinion unnecessarily) difficult for record sets.


I'm really on your side with your analysis of ORM defects, so I'm saying this in the most constructive sense.

Regards


Paolo



Rainer Döbele wrote:
Hi Paolo,

even though what you want is possible with Empire-db, it is not the recommended 
approach.
Your desire to obtain a List<DBRecord> is more the way traditional OR-Mappers 
work and that I criticize: They usually force you to work with data bean objects that 
match a record of the database table (full entity beans) even though it is in most 
cases (as with almost every list) neither necessary nor required. Especially when you 
have user interaction then a list you present to the user rarely shows a single table 
with all its columns.

For a better understanding I recommend reading the following article http://incubator.apache.org/empire-db/empiredb/hibernate.htm
especially the section "Dynamic queries: The select dilemma"

So what I recommend is the following:
1. Use DBCommand and DBReader to obtain and present a list to the user. Select 
the primary key and only columns that you want to display to the user. You may 
use reader.getBeanList() to obtain a list of traditional Java Beans for your 
list display needs.

2. If the user selects a in individual record, read it user DBReader.read(). 
The entire record then will be fetched from the database and you may change and 
update it. Then the user may select and change another record.

Alternatively if multiple records are to be changed on one click of a button, 
then do the following:
- Perform a new query for all records that need to be changed and iterate 
though them using a DBReader.
- Initialize a DBRecord object for the current row using initRecord() - With the DBRecord change the value and call update().
- Continue with the next record.

Regards
Rainer

Reply via email to