Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » problem with entityManager.createQuery(CriteriaQuery q)
problem with entityManager.createQuery(CriteriaQuery q) [message #1047710] Tue, 23 April 2013 14:51 Go to next message
rachid elmaazouz is currently offline rachid elmaazouzFriend
Messages: 1
Registered: April 2013
Junior Member
Hi all
I am facing a strange problem with entityManager method *createQuery(CriteriaQuery)* I got the following error:

 Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.createCompoundQuery( 
	at org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl.translate(
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(
	at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(
	at com.sun.ejb.EjbInvocation.proceed(
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(

it is reported as a bug but I use the latest EclipseLink api (2.4.x), and the strange thing is when I test the EJB responsible of throwing this exception using an EJB client, everything works fine as expected but integrating this with the web part it just flat away with errors.
Here is the function overrided *load* since I use Primefaces API for my presentation layer:

	public List<ApplicationDTO> load(
			int first,
			int pageSize,
			String sortedField,
			com.mobiwigo.common.dataaccess.IDataAccessProxy.SortOrder sortOrder,
			Map<String, String> filters) {

		CriteriaBuilder cb = entityManager.getCriteriaBuilder();
		CriteriaQuery<ApplicationDTO> q = cb.createQuery(ApplicationDTO.class);
		Root<Application> a = q.from(Application.class);

		applyFilter(a, cb, q, filters);
		applySort(cb, q, a, sortedField, sortOrder);, a));

		return entityManager.createQuery(q).setFirstResult(first)

the functions applySort and applyFilter are

private void applySort(CriteriaBuilder cb, CriteriaQuery<ApplicationDTO> q,
			Root<Application> a, String sortedField, SortOrder sortOrder) {
        if(sortedFiled != null){
		if (sortOrder == SortOrder.ASC) {



		if (sortOrder == SortOrder.DESC) {


	private void applyFilter(Root<Application> a, CriteriaBuilder cb,
			CriteriaQuery<ApplicationDTO> q, Map<String, String> filters) {

        if(filters != null){

		List<Predicate> predicates = new ArrayList<Predicate>();

		for (String s : filters.keySet()) {

			if (a.get(s) != null) {

				predicates.add(<String> get(s),
						"%" + filters.get(s) + "%"));

		q.where(cb.and(predicates.toArray(new Predicate[predicates.size()])));



Re: problem with entityManager.createQuery(CriteriaQuery q) [message #1049350 is a reply to message #1047710] Thu, 25 April 2013 18:43 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1289
Registered: July 2009
Senior Member
The bug I believe you are refering to is and I've verified is fixed in 2.4.x stream. What version/build are you using? You can verify the version by enabling Eclipselink logging I believe to fine, and it will be logged at login. The web component might be using a different version of the EclipseLink jar from the one that is working.

[Updated on: Thu, 25 April 2013 18:44]

Report message to a moderator

Previous Topic:One to One Relationship With Shared PK not Working at Execution time
Next Topic:insert always null on embedded fields
Goto Forum:

Current Time: Fri Mar 23 07:02:02 GMT 2018

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

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