2.1.3
org.springframework.orm.hibernate.HibernateObjectRetrievalFailureException: No row with the given identifier exists: 0, of class: au.edu.tlf.lips.model.RightsType; nested exception is net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: au.edu.tlf.lips.model.RightsType
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: au.edu.tlf.lips.model.RightsType
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1943)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:232)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2194)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at org.springframework.orm.hibernate.HibernateTemplate$21.doInHibernate(HibernateTemplate.java:407)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:196)
at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:404)
at au.edu.tlf.lips.persistence.hibernate.RightsTypeDAOHibernate.getAllRightsTypes(RightsTypeDAOHibernate.java:45)
at au.edu.tlf.lips.service.RightsTypeManagerImpl.getAllRightsTypes(RightsTypeManagerImpl.java:53)
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:324)
at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy13.getAllRightsTypes(Unknown Source)
at au.edu.tlf.lips.webapp.action.RightsTypeController.handleRequest(RightsTypeController.java:82)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:495)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:73)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.opensymphony.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:42)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at au.edu.tlf.lips.webapp.filter.ActionFilter.doFilter(ActionFilter.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at au.edu.tlf.lips.webapp.filter.BreadcrumbFilter.doFilter(BreadcrumbFilter.java:146)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:170)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at au.edu.tlf.lips.webapp.filter.GZIPFilter.doFilter(GZIPFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:534)
MySQL 4.0.18
I have a class that is a zero-to-many composite of itself
(i.e.) an instance of MyClass can be the parent of another
instance of MyClass
public class MyClass {
Long id;
String name;
MyClass childOf;
}
I have been trying to follow the steps detailed in the
tutorial about setting up hibernate mapping betweens objects
but I'm a little stuck here. Do I need another attribute to
reference the parent in MyClass?
I followed the steps I saw listed at
http://www.hibernate.org/209.html
And made a stab at it trying the code listed below
public class RightsType extends BaseObject {
// Instance variables
private Long id;
private String name;
private String description;
private RightsType childOf;
// Compositions
public List conditionTypes;
public List rights;
public Set childRightTypes;
/**
* Default construtor
*/
public RightsType() {
super();
}
/**
* @return Returns the childOf.
* @hibernate.bag
* name="rights_types"
* table="rights_type_children"
* cascade="save-update"
* lazy="false"
* inverse="true"
* @hibernate.collection-key
* column="parent_rights_type_id"
* @hibernate.collection-one-to-many
* class="au.edu.tlf.lips.model.RightsType"
*/
public RightsType getChildOf() {
return childOf;
}
/**
* @param childOf The childOf to set.
*/
public void setChildOf(RightsType childOf) {
this.childOf = childOf;
}
/**
* @return Returns the childRightTypes.
* @hibernate.many-to-one
* column="parent_rights_type_id"
* not-null="true"
* class="au.edu.tlf.lips.model.RightsType"
*/
public Set getChildRightTypes() {
return childRightTypes;
}
/**
* @param childRightTypes The childRightTypes to set.
*/
public void setChildRightTypes(Set childRightTypes) {
this.childRightTypes = childRightTypes;
}
}
When I compile and run the code then try to access my JSP that calls the code I get
org.springframework.orm.hibernate.HibernateObjectRetrievalFailureException: No row with the given identifier exists: 0, of class: au.edu.tlf.lips.model.RightsType; nested exception is net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: au.edu.tlf.lips.model.RightsType
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 0, of class: au.edu.tlf.lips.model.RightsType
I understand that this happens because I have said the parentId cannot be null but if I set it to allow null values I get
net.sf.hibernate.PropertyAccessException: exception setting
property value with CGLIB (set
hibernate.cglib.use_reflection_optimizer=false for more info)
Any ideas or suggestions as to what I am doing incorrectly?
Thanks in advance,