Andrus Adamchik wrote:
>
> On Sep 11, 2005, at 12:23 PM, Hefest wrote:
>
>> SQLTemplate has a fixation on a root object
>
>
> "Root" is also need for query routing. So for queries that do not
> result in instantiating DataObjects the most sensible thing is to set
> its root to DataMap. Or to save a few lines of code, pass it some
> DataObject class from that map, even if you don't fetch it. But you
> also need another piece to make sure it can fetch arbitrary data:
>
> sqlTemplate.setFetchingDataRows(true);
>
>
> You can do an equivalent thing in the Modeler, just uncheck 'Fetch
> Data Objects'. There was a bug that is already fixed in 1.2 that may
> have caused some confusion - http://objectstyle.org/jira/secure/
> ViewIssue.jspa?key=CAY-303
Thanks for the advice, it led me to the following (working) solution:
Date now = null;
SQLTemplate template = new SQLTemplate(
(DataMap) dataContext.getDataMaps().iterator().next(),
"SELECT getdate() AS current", true);
template.setFetchingDataRows(true);
List output = dataContext.performQuery(template);
if (output.size() > 0) {
DataRow redak = (DataRow) output.iterator().next();
now = (Date) redak.get("current");
}
return now;
Regards,
Tomislav
This archive was generated by hypermail 2.0.0 : Mon Sep 12 2005 - 08:35:55 EDT