Hi Marco,
 
first I assume that you are referring to the DBReader.getBeanList() method, 
which is a way of obtaining the results of a query as a list of java bean 
objects or POJO's.
 
Empire-db does not depend on POJO's to hold data as OR-Mappers do. Hence we 
don't assume that there are POJO's that match the internal data model. In fact 
you could make transformations on your colums such as for example concatenating 
database columns, or perform calculations or aggregation of columns. After all 
this is what DBMS are designed for.
 
So the idea behind the DBReader.getBeanList() method is, that you provide a 
(flat) java object that has been exclusively designed to hold the result of 
your query, because that will give you the most convenient way to work with the 
result (e.g. to display the result to the user).
 
But nevertheless what you want to achieve is also possible, although it 
requires a little step in between. Internally Empire-db maps column expressions 
to bean properties using the function getBeanPropertyName(). You may provide a 
name using setBeanPropertyName().
 
DBColumnExpr mappedExpr = ADDRESS.STREET.as("STREET");
mappedExpr.setBeanPropertyName("adresss.street");
cmd.select(mappedExpr);
 
Using the .as() renaming function ensures that the property mapping is only 
used for this particular query and not generally for the adress.street column - 
otherwise you could skip that. I must admit that we could make this more 
convenient by allowing something like:
 
cmd.select(ADDRESS.STREET.as("adresss.street"));
 
But at the moment this is not yet possible. The question is whether it's worth 
implementing since as I explained the idea is not to work with POJO's matching 
the relational model as OR-Mappers do. So give us a good reason a we'll put it 
on our list of improvements.
 
Regards
Rainer

P.S. For more information see 
http://incubator.apache.org/empire-db/empiredb/hibernate.htm


Marco Behler wrote:
> Hi there,
> suppose I have a User class
> 
> public class User {
>        private Address address;
>        ...
> }
> 
> and a select command that looks like:
> 
> cmd.select(USER.USER_ID, USER.FIRST_NAME, USER.LAST_NAME ....)
> cmd.select(ADDRESS.STREET, ADDRESS.POSTAL_CODE ...)
> cmd.join(USER.ADDRESS_ID, ADDRESS.ADDRESS_ID)
> 
> I was having a look at the tutorials, but did not find a way or method
> to get DBReader to populate the "address" property of the user object.
> How can that be done?
> 
> Cheers!

<<winmail.dat>>

Reply via email to