Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NullPointerException in CriteriaQueryImpl when using multiselect
NullPointerException in CriteriaQueryImpl when using multiselect [message #659930] Wed, 16 March 2011 08:43 Go to next message
Lucas Persson is currently offline Lucas PerssonFriend
Messages: 3
Registered: March 2011
Junior Member
Hi

I get a NullPointerException when caling EntityManager.createQuery(criteria)
at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryI mpl.createCompoundQuery(CriteriaQueryImpl.java:543)
(I am using EclipseLink 2.1 from within Weblogic 10.3.4, I have also tried EclipseLink 2.3)

Here is the code:
public List<Tuple> getTopUsage( int lenght) {
CriteriaBuilder builder = mEntityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> criteria = builder.createTupleQuery();

SingularAttribute<Cdr, String> attribute = Cdr_.callingParty;
Root<Cdr> cdr = criteria.from(Cdr.class);

criteria.multiselect(cdr.get(attribute), builder.count(cdr.get(attribute)));
criteria.where(builder.conjunction());
criteria.groupBy(cdr.get(attribute));

TypedQuery<Tuple> query = mEntityManager.createQuery(criteria);
query.setMaxResults(lenght);
List<Tuple> list = query.getResultList();
return list;
}

Checking the code in EclipseLink then it (createCompoundQuery) assumes that the criteriaQuery's where member always has a "current node" and that is not the case with a predicate like the one I can get from the builder like this: builder.conjunction().

(in my real code I pass in some parameters to build up the 'where' clause)

Here is the stacktrace.

java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryI mpl.createCompoundQuery(CriteriaQueryImpl.java:543)
at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryI mpl.translate(CriteriaQueryImpl.java:715)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.creat eQuery(EntityManagerImpl.java:1313)
at sun.reflect.GeneratedMethodAccessor168.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.persistence.QueryProxyImpl.instantiateQuery(QueryPr oxyImpl.java:56)
at weblogic.persistence.QueryProxyImpl.createQuery(QueryProxyIm pl.java:74)
at weblogic.persistence.QueryProxyImpl.getResultList(QueryProxy Impl.java:145)
at xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.CdrBeanImpl.getTopUsage(CdrBea nImpl.java:230)


Thanks
Lucas

Re: NullPointerException in CriteriaQueryImpl when using multiselect [message #660039 is a reply to message #659930] Wed, 16 March 2011 15:59 Go to previous messageGo to next message
Michael OBrien is currently offline Michael OBrienFriend
Messages: 34
Registered: July 2009
Member
Lucas,
Hi, thank you for finding this serious issue - a NullPointerException is uncceptable.
It would be better if you (as a valued user) raised a bug on the NPE resulting from line 543. We can the address a non-existent currentNode for the rest of the code in that function.

if (this.where != null && ((InternalSelection) this.where).getCurrentNode().getBuilder().getQueryClass() != null) {


https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseL ink

/ Michael O'Brien
http://www.eclipselink.org
Re: NullPointerException in CriteriaQueryImpl when using multiselect [message #660261 is a reply to message #660039] Thu, 17 March 2011 15:25 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
This was cross posted here:
http://forums.oracle.com/forums/thread.jspa?threadID=2188540 &tstart=0

I believe it is bug 316144 which was fixed in EclipseLink 2.2. Please try the latest version of EclipseLInk before filing a new bug.

Best Regards,
Chris
Re: NullPointerException in CriteriaQueryImpl when using multiselect [message #661109 is a reply to message #660261] Wed, 23 March 2011 08:54 Go to previous message
Lucas Persson is currently offline Lucas PerssonFriend
Messages: 3
Registered: March 2011
Junior Member
Hi Chris

I have already filed a bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=340280

I have also tried EclipseLink 2.3.0.v20110202-r8914 (since that happen so be part of Weblogic 11.0.0.0.0 under development) with the same issue.

I checked the bug you mention but I do not think that this is the same issue.


Thanks
Lucas

[Updated on: Wed, 23 March 2011 08:56]

Report message to a moderator

Previous Topic:EclipseLink DBWS Deployment Dependencies
Next Topic:Convert query to native query
Goto Forum:
  


Current Time: Wed Apr 24 18:18:28 GMT 2024

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

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

Back to the top