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 Hoffmann
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:
java.lang.NullPointerException
at org.eclipse.persistence.internal.expressions.ObjectExpression.existingDerivedExpressionNamed(ObjectExpression.java:254)
at org.eclipse.persistence.internal.expressions.ObjectExpression.derivedExpressionNamed(ObjectExpression.java:223)
at org.eclipse.persistence.internal.expressions.ObjectExpression.get(ObjectExpression.java:267)
at org.eclipse.persistence.expressions.Expression.get(Expression.java:1529)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$FetchHint.applyToDatabaseQuery(QueryHintsHandler.java:1376)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(QueryHintsHandler.java:361)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(QueryHintsHandler.java:339)
at org.eclipse.persistence.internal.jpa.QueryHintsHandler.apply(QueryHintsHandler.java:171)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHintInternal(EJBQueryImpl.java:1021)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHint(EJBQueryImpl.java:1003)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHint(EJBQueryImpl.java:81)
...


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 http://www.eclipse.org/forums/index.php?t=rview&goto=556078.

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 Sutherland
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,

session.getProject().setJPQLParseCacheMaxSize(0);



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: Wed Sep 17 05:34:35 GMT 2014

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

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