Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate Exception - could not resolve property:
    primarykey
    data
    text
    <p>I am trying to retrieve an object and its children. The request comes up with an exception.</p> <p>Models - The staff class is a self reference class where the checker with a checker_id is also a staff. And also both the staff and checker has a one to many relationship with the module model.</p> <pre><code> public class Staff implements Serializable, @Id @Column(name = "staff_id") private String staffId; @ManyToOne(cascade={CascadeType.ALL}) @JoinColumn(name="checker_id") private Staff checker; @OneToMany(mappedBy="checker", orphanRemoval=true, cascade = CascadeType.ALL) private Set&lt;Staff&gt; setters = new HashSet&lt;Staff&gt;(); @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="setter") private Set&lt;Module&gt; sModule = new HashSet&lt;Module&gt;(); @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="checker") private Set&lt;Module&gt; cModule = new HashSet&lt;Module&gt;(); //getters and setters} </code></pre> <p>Module model</p> <pre><code> public class Module implements Serializable{ @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="staff_id", insertable=false, updatable=false) private Staff setter; @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="checker_id", insertable=false, updatable=false) private Staff checker; //getters and setters } </code></pre> <p>DAO code</p> <pre><code> @Transactional @SuppressWarnings("unchecked") public Staff getWithModules(String staffId){ //Retrieve Staff Criteria crit = getCurrentSession().createCriteria(Staff.class); crit.add(Restrictions.eq("staffId", staffId)); Staff staff = get(crit); //Retrieve the modules for the staff crit = getCurrentSession().createCriteria(Module.class); crit.add(Restrictions.eq("Staff.staffId", staffId)); crit.add(Restrictions.isNull("checkerId")); crit.addOrder(Order.asc("moduleId")); Set&lt;Module&gt; sModule = new LinkedHashSet&lt;Module&gt;(crit.list()); staff.setsModule(sModule); //Set&lt;Module&gt; modules = new LinkedHashSet&lt;Module&gt;(crit.list()); //staff.setModules(modules); return staff; } </code></pre> <p>When I try to get any staff id and along with it the modules attached to it. I get this error in the stacktrace:</p> <pre><code> org.hibernate.QueryException: could not resolve property: Staff of: com.project.professional.model.Module org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77) org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1945) org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:61) org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1920) org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:523) org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:538) org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:66) org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:419) org.hibernate.loader.criteria.CriteriaJoinWalker.&lt;init&gt;(CriteriaJoinWalker.java:123) org.hibernate.loader.criteria.CriteriaJoinWalker.&lt;init&gt;(CriteriaJoinWalker.java:92) org.hibernate.loader.criteria.CriteriaLoader.&lt;init&gt;(CriteriaLoader.java:95) org.hibernate.internal.SessionImpl.list(SessionImpl.java:1602) org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374) com.project.professional.dao.StaffDAO.getWithModules(StaffDAO.java:60) com.project.professional.dao.StaffDAO$$FastClassByCGLIB$$d033d033.invoke(&lt;generated&gt;) org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) com.project.professional.dao.StaffDAO$$EnhancerByCGLIB$$58379429.getWithModules(&lt;generated&gt;) com.project.professional.service.StaffServiceImpl.getWithModules(StaffServiceImpl.java:54) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) $Proxy46.getWithModules(Unknown Source) com.project.professional.controller.StaffController.showStaffModules(StaffController.java:83) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:746) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) </code></pre> <p>I would appreciate knowing what the problem is. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload