Well, as the COMPANY_ID is null, that's not even valid faults... A few
things to check before looking any deeper:
1. Is Company mapped as an ObjEntity, with an underlying DbEntity. This
is a requirement in the current version to turn result into DataObjects
(in the future versions we will support mapping of ObjEntity to a
SQLTemplate bypassing DbEntity, and mapping an arbitrary Java class to
a SQLTemplate)
2. Try replacing "SELECT *" with a specific list of columns, creating
column aliases using "#result" directive (see 7.7.2 -
http://objectstyle.org/cayenne/userguide/fetch/sqltemplate-
scripting.html). This may be needed on some databases due to possible
column name capitalization issues (e.g. you can have a DbAttribute
called "Company_ID", while ResultSet column as returned by the DB by
default may be called "company_id", or "COMPANY_ID", so explicit column
naming is needed).
Andrus
On Sep 9, 2004, at 1:33 PM, Gentry, Michael wrote:
> I've not used SQLTemplate, but it looks to me like you have a List of
> faults. Trying to do something with those 10 Company objects will
> probably fault them in from the database.
>
> /dev/mrg
>
>
> -----Original Message-----
> From: news [mailto:new..ea.gmane.org] On Behalf Of Bryan Lewis
> Sent: Thursday, September 09, 2004 12:07 PM
> To: cayenne-use..bjectstyle.org
> Subject: how to use SQLTemplate
>
>
> I must be missing something about SQLTemplate. I updated to version
> 1.1B2 and tried a simple example like the one in the User Guide:
>
> String sql = "SELECT * FROM COMPANY";
> SQLTemplate query = new SQLTemplate(Company.class, sql, true);
> query.setFetchLimit(10);
> List companies = dataContext.performQuery(query);
> log.debug("companies = " + companies);
>
> I get a list of 10 empty objects.
>
> companies = [{[]<oid: model.Company: <Company_ID: null>; state:
> hollow>}
> , {[]<oid: model.Company: <Company_ID: null>; state:
> hollow>}
> ...
>
> I see that other people are using SQLTemplate; what am I missing?
>
> Thanks,
> Bryan
>
>
This archive was generated by hypermail 2.0.0 : Thu Sep 09 2004 - 22:49:47 EDT