Balazs Kanyo
Balazs Kanyo

Reputation: 183

Hibernate HQL createQuery NullPointerException

I can't find out why throw this expression always a 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
...

Other requests successfully executed.

Upvotes: 0

Views: 1873

Answers (1)

JB Nizet
JB Nizet

Reputation: 691635

The second argument is supposed to be the type of the objects that the query will return. But this query doesn't return anything, since it's a delete query.

I don't know why it throws a NullPointerException (it shouldn't), but what's sure is that you should use the createQuery() method without a Class argument.

Upvotes: 1

Related Questions