Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NullPointerException in Query.setHint with join-fetch/batch(NullPointerException at ObjectExpression.existingDerivedExpressionNamed(
NullPointerException in Query.setHint with join-fetch/batch [message #757300] 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 2.3.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 NullPointerException in QueryKeyExpression.getQueryKeyOrNull.

It is possible to avoid this exception e.g. by JPA configuration (disable expression cache) or is a fix available?

[Updated on: Sat, 19 November 2011 17:24]

Report message to a moderator

Re: Title: NullPointerException in Query.setHint with join-fetch/batch [message #758044 is a reply to message #757300] Mon, 21 November 2011 19:53 Go to previous message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
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 : : :
Previous Topic:Title: NullPointerException in Query.setHint with join-fetch/batch
Next Topic:JPA query - NOT MEMBER OF exception
Goto Forum:

Current Time: Tue Jun 19 01:17:22 GMT 2018

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

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

Back to the top