0

我不知道为什么总是抛出这个表达式 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
...

其他请求成功执行。

4

1 回答 1

1

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

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

于 2012-06-19T08:21:40.647 回答