Thanks very much. This worked for me.
-----Original Message-----
From: Scott Eade [mailto:seade@;backstagetech.com.au]
Sent: Sunday, November 03, 2002 5:56 PM
To: Turbine Torque Users List
Subject: Re: LargeSelect Question
> From: "Tony Spencer" <[EMAIL PROTECTED]>
>
> LargeSelect ret = null;
> Criteria crit = new Criteria();
> Criteria.Criterion a = crit.getNewCriterion(HousingPeer.SUBCATEGORYID,
> String.valueOf(subCategoryId), Criteria.EQUAL);
> Criteria.Criterion b = crit.getNewCriterion(HousingPeer.EMAIL_CONFIRMED,
> "false", Criteria.NOT_EQUAL);
> crit.add(a.and(b));
> crit.addDescendingOrderByColumn(HousingPeer.DATE_POSTED);
> crit.setDbName("tonys_raleigh");
>
> ret = new LargeSelect(crit, 10, 2);
>
> Running the code and attempting to access the first page of results
> generates the following SQL which has errors (there are no columns
specified
> after 'SELECT').
>
> SELECT FROM housing WHERE (housing.SUBCATEGORYID='1003' AND
> housing.EMAIL_CONFIRMED<>'false')
> ORDER BY housing.DATE_POSTED DESC LIMIT 21
>
> Also, why do I have to set the dbName in the Criteria? I never had to do
> this when doing a HousingPeer.doSelect but I found that not specifying the
> dbName resulted in Torque attempting to get a connection for database
named
> "default".
Tony,
The LargeSelect constructors that do not include a returbBuilderClassName
argument require you to add the select columns to the criteria manually. In
your case, as you are simply querying a standard OM object you can pass the
peer class itself as the returnBuilderClassName thus:
Criteria crit = new Criteria();
Criteria.Criterion a = crit.getNewCriterion(HousingPeer.SUBCATEGORYID,
String.valueOf(subCategoryId), Criteria.EQUAL);
Criteria.Criterion b = crit.getNewCriterion(HousingPeer.EMAIL_CONFIRMED,
"false", Criteria.NOT_EQUAL);
crit.add(a.and(b));
crit.addDescendingOrderByColumn(HousingPeer.DATE_POSTED);
LargeSelect ret = new LargeSelect(crit, 10, 2,
"com.mycompany.project.om.HousingPeer");
It will no longer be necessary to set the database name and the results will
be returned as Housing objects (make sure you use your real package name,
not the one I made up).
Alternatively you could go:
Criteria crit = new Criteria();
Criteria.Criterion a = crit.getNewCriterion(HousingPeer.SUBCATEGORYID,
String.valueOf(subCategoryId), Criteria.EQUAL);
Criteria.Criterion b = crit.getNewCriterion(HousingPeer.EMAIL_CONFIRMED,
"false", Criteria.NOT_EQUAL);
crit.add(a.and(b));
crit.addDescendingOrderByColumn(HousingPeer.DATE_POSTED);
crit.addSelectColumn(HousingPeer.HOUSING_ID);
//crit.addSelectColumn(HousingPeer.OTHER_COLUMN);
//...
LargeSelect ret = new LargeSelect(crit, 10, 2,
"com.mycompany.project.om.HousingPeer");
Again it is no longer necessary to set the database name, but this time the
results will be returned as Village Records. The LargeSelect javadoc
provides the information necessary to construct a class that allows you to
work with an arbitrary set of columns in the first of these two formats
(which makes life much easier).
Cheers,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
--
To unsubscribe, e-mail:
<mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:turbine-torque-user-help@;jakarta.apache.org>
--
To unsubscribe, e-mail: <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>