Criteria Hibernate - Error

0

I'm getting the following Exception , I looked at my code and I can not find the error.

The query is performed and returns the objects, but when it returns, it throws the exception .

@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public List<RespostaRequerimento> consultar(ConsultarFilter filter) throws DAOException {
    Session session =  this.getEntityManager().unwrap(Session.class);

    Criteria criteria =  session.createCriteria(RespostaRequerimento.class);
    adicionarFiltro(filter, criteria);

    return criteria.list(); 
}

private void adicionarFiltro(ConsultarFilter filtro, Criteria criteria) {
    if(filtro !=null){
        if(!StringUtils.isEmpty(filtro.getUsuario())){
            criteria.add(Restrictions.like("usuario", filtro.getUsuario()));
        }
    }
}
  

java.lang.NullPointerException at   RequestServiceImpl.consult (RequestInquiryServiceServiceImpl.java:102)   at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at   sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)   at   sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)   at java.lang.reflect.Method.invoke (Method.java:597) at   org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (AopUtils.java:302)   at   org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:202)   at $ Proxy41.consultar (Unknown Source) at   br.com.experian.srv.respostaanalysiscorrector.core.service.ConsultResponse RequirementServiceTest.deveConsultForUser (RequestInquiry RequestServiceTest.java:194)   at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at   sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)   at   sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)   at java.lang.reflect.Method.invoke (Method.java:597) at   org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall (FrameworkMethod.java:47)   at   org.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java:12)   at   org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java:44)   at   org.junit.internal.runners.statements.InvokeMethod.evaluate (InvokeMethod.java:17)   at   org.junit.internal.runners.statements.RunBefores.evaluate (RunBefores.java:26)   at   org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate (RunBeforeTestMethodCallbacks.java:75)   at   org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate (RunAfterTestMethodCallbacks.java:86)   at   org.springframework.test.context.junit4.statements.SpringRepeat.evaluate (SpringRepeat.java:84)   at org.junit.runners.ParentRunner.runLeaf (ParentRunner.java:271) at   org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (SpringJUnit4ClassRunner.java:254)   at   org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (SpringJUnit4ClassRunner.java:89)   at org.junit.runners.ParentRunner $ 3.run (ParentRunner.java:238) at   org.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java:63) at   org.junit.runners.ParentRunner.runChildren (ParentRunner.java:236) at   org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java:53) at   org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java:229) at   org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate (RunBeforeTestClassCallbacks.java:61)   at   org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate (RunAfterTestClassCallbacks.java:70)   at org.junit.runners.ParentRunner.run (ParentRunner.java:309) at   org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (SpringJUnit4ClassRunner.java:193)   at   org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java:86)   at   org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38)   at   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:459)   at   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:678)   at   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:382)   at   org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:192)

    
asked by anonymous 23.05.2017 / 21:57

0 answers