Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.2 branch, 2.0 branch, 3.0
-
None
Description
http://objectstyle.org/cayenne/lists/cayenne-user/2006/12/0169.html
When a macro appears at the end of line, and the next line has no leading space, an error occurs during SQLTemplate processing as two tokens are concatenated with each other:
String template = "SELECT #result('count' 'int' 'X')"
+ System.getProperty("line.separator")
+ "FROM ARTIST ORDER BY ARTIST_ID";
SQLTemplate query = getSQLTemplateBuilder().createSQLTemplate(
Artist.class,
template);
query.setFetchingDataRows(true);
List result = context.performQuery(query);
NFO: SELECT count AS XFROM ARTIST ORDER BY ARTIST_ID
Dec 26, 2006 1:27:02 PM org.apache.cayenne.access.QueryLogger logQueryError
INFO: *** error.
java.sql.SQLException: Unexpected token ARTIST, requires FROM in statement [SELECT count(*) AS XFROM ARTIST ORDER BY ARTIST_ID]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.apache.cayenne.conn.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:274)
at org.apache.cayenne.conn.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:280)
at org.apache.cayenne.access.TransactionConnectionDecorator.prepareStatement(TransactionConnectionDecorator.java:179)
at org.apache.cayenne.access.jdbc.SQLTemplateAction.execute(SQLTemplateAction.java:132)
at org.apache.cayenne.access.jdbc.SQLTemplateAction.performAction(SQLTemplateAction.java:109)
at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:57)
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:236)
at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:413)
at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:64)
at org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:385)
at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:800)
at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:382)
at org.apache.cayenne.access.UnitTestDomainQueryAction.runQueryInTransaction(UnitTestDomainQueryAction.java:53)
at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:116)
at org.apache.cayenne.access.UnitTestDomainQueryAction.execute(UnitTestDomainQueryAction.java:48)
at org.apache.cayenne.access.UnitTestDomain.onQuery(UnitTestDomain.java:62)
at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:282)
at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:59)
at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1308)
at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1297)
at org.apache.cayenne.access.DataContextSQLTemplateTest.testQueryWithLineBreakAfterMacro(DataContextSQLTemplateTest.java:174)