openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang yu <wangy...@gmail.com>
Subject Timestamp in JPQL where clause issue
Date Mon, 27 Jul 2009 06:20:43 GMT
Hello,
I met an OpenJPA Timestamp filed in JPQL where clause issue.
I used it as:
		EntityManagerFactory factory = Persistence.createEntityManagerFactory(
				"test", System.getProperties());		
		String sql= "SELECT callpath FROM Callpath callpath WHERE
callpath.starttime > :from";
		Query query = factory.createEntityManager().createQuery(sql);
		query.setParameter("from", new
Timestamp(System.currentTimeMillis()), TemporalType.TIMESTAMP);
		query.getResultList();

The Exception stack:
<openjpa-1.2.1-r752877:753278 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: Encountered
"callpath . starttime > : from" at character 46, but expected: ["(",
"*", "+", "-", ".", "/", ":", "<", "<=", "<>", "=", ">", ">=", "?",
"ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG", "BETWEEN", "BOTH",
"BY", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME",
"CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE",
"EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN", "INNER", "IS",
"JOIN", "LEADING", "LEFT", "LENGTH", "LIKE", "LOCATE", "LOWER", "MAX",
"MEMBER", "MIN", "MOD", "NEW", "NOT", "NULL", "OBJECT", "OF", "OR",
"ORDER", "OUTER", "SELECT", "SET", "SIZE", "SOME", "SQRT",
"SUBSTRING", "SUM", "TRAILING", "TRIM", "UPDATE", "UPPER", "WHERE",
<DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL>].
	at org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9501)
	at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9378)
	at org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1947)
	at org.apache.openjpa.kernel.jpql.JPQL.conditional_factor(JPQL.java:1925)
	at org.apache.openjpa.kernel.jpql.JPQL.conditional_term(JPQL.java:1791)
	at org.apache.openjpa.kernel.jpql.JPQL.conditional_expression(JPQL.java:1753)
	at org.apache.openjpa.kernel.jpql.JPQL.where_clause(JPQL.java:1556)
	at org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:91)
	at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63)
	at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1740)
	at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1727)
	at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48)
	at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149)
	at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:657)
	at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:625)
	at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
	at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
	at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
	at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
	at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
	at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)

And I noticed a bug track:
http://mail-archives.apache.org/mod_mbox/openjpa-dev/200801.mbox/%3C2013506.1200781234450.JavaMail.jira@brutus%3E

Has it been resolved? Or do I have a workaround?

Thanks!

Regards,
Yu Wang

Mime
View raw message