Hibernate HQL createQuery NullPointerException

时间:2012-06-19 08:14:13

标签: hibernate jpa nullpointerexception

我无法找出为什么抛出这个表达式总是一个NullPointerException:

String jpql = "DELETE Trend t WHERE t.owner = :owner AND t.shapeId = :shapeid AND t.security = :security AND t.timeframe = :timeframe";         
int rows = 0;       
try {           
Query q = em.createQuery(jpql, Trend.class); // this line throw the exception
...

其他请求已成功执行。

1 个答案:

答案 0 :(得分:1)

第二个参数应该是查询将返回的对象的类型。但是这个查询不会返回任何内容,因为它是一个删除查询。

我不知道它为什么抛出NullPointerException(它不应该),但是你应该使用createQuery()方法而没有Class参数。

相关问题