Question

I have this class:

@Entity
@Table(name = "TOPUP_MESSAGE")
public class ReportFee {
  //... ID & Other Properties
  @ManyToOne
  @JoinColumn(name="CONTRACT_ID")
  private ContractDetail contractDetail;
  //GETTERS AND SETTERS
}

and ContractDetail class is like this:

@Entity
@Table(name = "CONTRACT_DETAIL")
public class ContractDetail {

  //... ID & Other Properties
  @ManyToOne
  @JoinColumn(name = "CONTRACT_ID")
  private Contract contract;
  //GETTERS AND SETTERS
}

My Contract class is like this:

@Entity
@Table(name = "CONTRACT")
public class Contract implements {

  //... ID & Other Properties
  @ManyToOne
  @JoinColumn(name = "OPERATOR_ID")
  private Operator operator;
  //GETTERS AND SETTERS
}

I defined my alias like this but It's wrong :

Session session = (Session)this.em.getDelegate();
Criteria crit = session.createCriteria(getEntityClass());
crit = crit.createAlias("contractDetail", "cd", JoinType.LEFT_OUTER_JOIN);
crit = crit.createAlias("contract", "c", JoinType.LEFT_OUTER_JOIN);
crit = crit.createAlias("operator", "op", JoinType.LEFT_OUTER_JOIN);

Criterion c= Restrictions.eq("cd.cd.op", operator);

crit.add(c);

List result = crit.list();

but unfortunately I get this error:

org.hibernate.QueryException: could not resolve property: contract of: x.be.ReportFee at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77) at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1809) at org.hibernate.loader.criteria.EntityCriteriaInfoProvider.getType(EntityCriteriaInfoProvider.java:57) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathInfo(CriteriaQueryTranslator.java:251) at org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:230) at org.hibernate.loader.criteria.CriteriaQueryTranslator.(CriteriaQueryTranslator.java:112) at org.hibernate.loader.criteria.CriteriaLoader.(CriteriaLoader.java:84) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1464) at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374) at x.findByCriteria(GenericJpaDao.java:195) at x.ReportFeeSb.getAllValidReportFees(ReportFeeSb.java:54) 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 com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37) at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54) at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy393.getAllValidReportFees(Unknown Source) at x.ReportFeeSi_kf36yv_ReportFeeSiImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40) at x.ReportFeeSi_kf36yv_ReportFeeSiImpl.getAllValidReportFees(Unknown Source) at x.ReportFeeSi_kf36yv_ReportFeeSiImpl_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174) at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:345) at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259) at x.ReportFeeSi_kf36yv_ReportFeeSiImpl_1034_WLStub.getAllValidReportFees(Unknown Source) 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 weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85) at $Proxy392.getAllValidReportFees(Unknown Source) 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 x.invoke(SlsbDynamicDelegate.java:66) at $Proxy391.getAllValidReportFees(Unknown Source) at xxx.ReportFeeBean.performAction(ReportFeeBean.java:61) 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 com.sun.el.parser.AstValue.invoke(Unknown Source) at com.sun.el.MethodExpressionImpl.invoke(Unknown Source) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) at javax.faces.component.UICommand.broadcast(UICommand.java:315) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207) at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

here is how the classes has been created :

----ReportFee (private ContractDetail contractDetail)

       |

        ------ ContractDetail (private Contract contract)

                      |

                       -------- Contract (private Contract contract)

how Am I going to solve this, thanx in advance ???

Was it helpful?

Solution

I solved this problem when I defined the nested hierarchy like this:

Session session = (Session)this.em.getDelegate();
Criteria crit = session.createCriteria(getEntityClass());
crit = crit.createAlias("contractDetail", "cd", JoinType.LEFT_OUTER_JOIN);
crit = crit.createAlias("cd.contract", "c", JoinType.LEFT_OUTER_JOIN);

Criterion criterion= Restrictions.eq("c.operator", operator);

crit.add(c);

List result = crit.list();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top