Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Title: NullPointerException in Query.setHint with join-fetch/batch
Title: NullPointerException in Query.setHint with join-fetch/batch [message #758001] Thu, 17 November 2011 15:31 Go to next message
Sven Hoffmann is currently offline Sven HoffmannFriend
Messages: 18
Registered: July 2009
Junior Member
Sometimes a NullPointerException occures while creating a JPA query with query hint eclipselink.join-fetch/eclipselink.batch.

The code performing the query looks like:

Query query = em.createNamedQuery(Container.LOAD_BY_ORDER);
query.setParameter("orderId", id);
query.setHint(QueryHints.FETCH, "c.attribute1");
query.setHint(QueryHints.BATCH, "c.attribute3");
List result = query.getResultList();

The stacktrace of the exception is:
at org.eclipse.persistence.internal.expressions.ObjectExpression.existingDerivedExpressionNamed(
at org.eclipse.persistence.internal.expressions.ObjectExpression.derivedExpressionNamed(
at org.eclipse.persistence.internal.expressions.ObjectExpression.get(
at org.eclipse.persistence.expressions.Expression.get(
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$FetchHint.applyToDatabaseQuery(
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(
at org.eclipse.persistence.internal.jpa.QueryHintsHandler.apply(
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHintInternal(
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHint(
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHint(

The application uses EclipseLink 3.2.1 M8 and is hosted on WebSphere Application Server 7.0 FP17 on an AIX system. The query is concurrently performed by message driven beans.
After one failure all subsequent calls fail with the same exception until the server is restarted.

I've found a similar issue described in

It is possible to avoid this exception e.g. by JPA configuration (disable expression cache) or is a fix available?
Re: Title: NullPointerException in Query.setHint with join-fetch/batch [message #758040 is a reply to message #758001] Mon, 21 November 2011 19:53 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The issue is although the hint causes different queries to be used, the same expression is still used, causing the concurrency issue.

Can you set the hint in the named query instead of dynamically (otherwise you are really not sharing the same query). If you have some queries that use join fetch, and some the use batch, then create multiple different named queries. Or use a dynamic JPQL query instead of changing a static defined one.

You could also synchronize on the DatabaseQuery's ExpressionBuilder while setting the hint. Please log a bug to have the concurrency issue fixed.

You can disable the JPQL cache using,


James : Wiki : Book : Blog : Twitter
Previous Topic:Must static-weaving be set in the persistence.xml file if static weaving has been performed
Next Topic:NullPointerException in Query.setHint with join-fetch/batch
Goto Forum:

Current Time: Thu May 24 04:38:01 GMT 2018

Powered by FUDForum. Page generated in 0.02076 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top