为什么我不能将@SqlResultSetMapping与查询光标提示一起使用

时间:2017-06-21 14:11:31

标签: java eclipselink sqlresultsetmapping

在Eclipselink中,当我使用@SqlResultSetMappings并使用查询提示eclipselink.cursor时,控制台会向我显示以下异常:

Caused By: java.lang.IllegalArgumentException: Query null, query hint eclipselink.cursor is not valid for this type of query.
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$CursorHint.applyToDatabaseQuery(QueryHintsHandler.java:1640)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(QueryHintsHandler.java:367)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(QueryHintsHandler.java:345)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler.apply(QueryHintsHandler.java:172)
at org.eclipse.persistence.internal.jpa.QueryImpl.setHintInternal(QueryImpl.java:763)
Truncated. see log file for complete stacktrace

代码是:

@SqlResultSetMapping(
    name = "resultSetMapping",
    entities = @EntityResult(entityClass = Entity.class))

Query q = em.createNativeQuery(sql, "resultSetMapping";
q.setHint(QueryHints.CURSOR, HintValues.TRUE);
q.getSingleResult();

为什么我不能在eclipselink.cursor中使用SqlResultSetMappings?

0 个答案:

没有答案