Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NullPointerException when using HAVING on JPQL
NullPointerException when using HAVING on JPQL [message #1750265] Mon, 19 December 2016 11:36
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
Registered: January 2012
Senior Member
Hi Folks.
With Eclipselink 2.6.4 and Oracle XE 11, running this Query:

SELECT u FROM Usuario u INNER JOIN u.sistemas s WHERE u.ativo = TRUE AND LOWER(u.email) = :email AND :sistema = s GROUP BY u HAVING COUNT(u.email) = 1


I got this error:
java.lang.NullPointerException
	at org.eclipse.persistence.queries.BatchFetchPolicy.getDataResults(BatchFetchPolicy.java:247)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:512)
	at org.eclipse.persistence.mappings.CollectionMapping.extractResultFromBatchQuery(CollectionMapping.java:898)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromBatchQuery(NoIndirectionPolicy.java:297)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.batchedValueFromRow(ForeignReferenceMapping.java:228)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2046)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject(ForeignReferenceMapping.java:1386)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:448)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:814)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:723)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:676)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:609)
	at org.eclipse.persistence.queries.ReportQueryResult.processItem(ReportQueryResult.java:209)
	at org.eclipse.persistence.queries.ReportQueryResult.buildResult(ReportQueryResult.java:143)
	at org.eclipse.persistence.queries.ReportQueryResult.<init>(ReportQueryResult.java:78)
	at org.eclipse.persistence.queries.ReportQuery.buildObject(ReportQuery.java:593)
	at org.eclipse.persistence.queries.ReportQuery.buildObjects(ReportQuery.java:644)
	at org.eclipse.persistence.queries.ReportQuery.executeDatabaseQuery(ReportQuery.java:847)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:852)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1109)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:393)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1197)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2879)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1607)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1589)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1554)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:231)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:442)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:382)
	at br.com.davinti.nauth.domain.dao.impl.UsuarioDaoImpl.getUsuarioAtivoPorEmailComAcesso(UsuarioDaoImpl.java:164)
	at sun.reflect.GeneratedMethodAccessor460.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy121.getUsuarioAtivoPorEmailComAcesso(Unknown Source)
	at br.com.davinti.nauth.spi.impl.UsuarioServiceImpl.getUsuarioPorEmailESenha(UsuarioServiceImpl.java:144)
	at sun.reflect.GeneratedMethodAccessor459.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
	at com.sun.proxy.$Proxy129.getUsuarioPorEmailESenha(Unknown Source)
	at br.com.davinti.nauth.ws.controller.UsuarioRestController.login(UsuarioRestController.java:136)
	at sun.reflect.GeneratedMethodAccessor457.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:108)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)


The email column is a Nullable Column, and its not unique. Users can be collected by, but only when its unique in the moment. Theres some error in the JPQL?

This is my Entity:

@Entity
@Table(name="USUARIO", indexes={@Index(unique=true, columnList="LOGIN ASC")})
@SequenceGenerator(name="USUARIO_SEQ", sequenceName="USUARIO_SEQ", allocationSize=1, initialValue=1)
@Cache(type=CacheType.SOFT,
		  size=1000,
		  expiry=60000,
		  coordinationType=CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS
		)
public class Usuario extends AbstractEntity<Integer> {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="USUARIO_ID")
	@GeneratedValue(generator="USUARIO_SEQ", strategy=GenerationType.AUTO)
	private Integer id;
	
	@Column(name="NOME", length=128, nullable=false)
	private String nome;
	
	@Column(name="LOGIN", length=32, nullable=false)
	@CacheIndex
	private String login;
	
	@Column(name="ALT_LOGIN", length=64)
	private String loginAlternativo;
	
	@Column(name="EMAIL", length=128)
	private String email;
	
	@Column(name="SENHA", length=128)
	private String senha;
	
	@Column(name="SALT", length=64)
	private String salt;
	
	@Column(name="EXPIRACAO")
	@Temporal(TemporalType.TIMESTAMP)
	private Date expiracaoSenha;
		
	@Column(name="ATIVO", nullable=false)
	private boolean ativo = true;
	
	@Column(name="SYNC_PROXY", nullable=false)
	private boolean syncProxy = false;
	
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name="USUARIO_GRUPO", indexes={@Index(unique=true, columnList="USUARIO_FK, GRUPO_FK")},
		joinColumns={@JoinColumn(name="USUARIO_FK", nullable=false)},
		inverseJoinColumns={@JoinColumn(name="GRUPO_FK", nullable=false)})
	@BatchFetch(value=BatchFetchType.IN, size=512)
	private Set<Role> roles = new HashSet<>();
	
	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="USUARIO_SISTEMA", uniqueConstraints= {@UniqueConstraint(columnNames= {"SISTEMA_ID", "USUARIO_ID"})},
		joinColumns= {@JoinColumn(name="USUARIO_ID", nullable=false)},
		inverseJoinColumns= {@JoinColumn(name="SISTEMA_ID", nullable=false)})
	private Set<Sistema> sistemas = new HashSet<>();
	
	@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval=true, mappedBy="usuario")
	@BatchFetch(value=BatchFetchType.IN, size=512)
	private List<UsuarioPropriedade> propriedades = new ArrayList<>();
	
	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="EMPRESA_USUARIO", indexes={@Index(unique=true, columnList="USUARIO_FK, EMPRESA_FK")},
		joinColumns={@JoinColumn(name="USUARIO_FK", nullable=false)},
		inverseJoinColumns={@JoinColumn(name="EMPRESA_FK", nullable=false)})
	private List<Empresa> empresas = new ArrayList<>();

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getLoginAlternativo() {
		return loginAlternativo;
	}

	public void setLoginAlternativo(String loginAlternativo) {
		this.loginAlternativo = loginAlternativo;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public Date getExpiracaoSenha() {
		return expiracaoSenha;
	}

	public void setExpiracaoSenha(Date expiracaoSenha) {
		this.expiracaoSenha = expiracaoSenha;
	}

	public boolean isAtivo() {
		return ativo;
	}

	public void setAtivo(boolean ativo) {
		this.ativo = ativo;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public Set<Sistema> getSistemas() {
		return sistemas;
	}

	public void setSistemas(Set<Sistema> sistemas) {
		this.sistemas = sistemas;
	}

	public List<UsuarioPropriedade> getPropriedades() {
		return propriedades;
	}

	public void setPropriedades(List<UsuarioPropriedade> propriedades) {
		this.propriedades = propriedades;
	}

	public List<Empresa> getEmpresas() {
		return empresas;
	}

	public void setEmpresas(List<Empresa> empresas) {
		this.empresas = empresas;
	}

	public boolean isSyncProxy() {
		return syncProxy;
	}

	public void setSyncProxy(boolean syncProxy) {
		this.syncProxy = syncProxy;
	}
	
}

[Updated on: Mon, 19 December 2016 11:43]

Report message to a moderator

Previous Topic:An exception was thrown while trying to load persistence unit at url: rsrc:..
Next Topic:Moxy - return class type for XML element
Goto Forum:
  


Current Time: Thu Nov 23 03:55:16 GMT 2017

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

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