z_xijiang
z_xijiang
2008-11-22 00:01

一个一对多双向自身关联的异常,求大家帮忙解答一下,非常感谢!!!

已采纳

mysql> select * from t_orgnization;
+----+------+------+-------------+------+
| id | name | sn | description | pid |
+----+------+------+-------------+------+
| 1 | org1 | NULL | NULL | NULL |
| 2 | org4 | NULL | NULL | 1 |
| 3 | org3 | NULL | NULL | 1 |
| 4 | org2 | NULL | NULL | 1 |
+----+------+------+-------------+------+
4 rows in set (0.00 sec)
这里是向数据表中添加一个父机构和3个子机构,这种情况没问题。
mysql> select * from t_orgnization;
+----+------+------+-------------+------+
| id | name | sn | description | pid |
+----+------+------+-------------+------+
| 1 | org1 | NULL | NULL | NULL |
| 2 | org4 | NULL | NULL | 1 |
| 3 | org3 | NULL | NULL | 1 |
| 4 | org2 | NULL | NULL | 1 |
| 5 | org1 | NULL | NULL | NULL |
| 6 | org4 | NULL | NULL | 5 |
| 7 | org3 | NULL | NULL | 5 |
| 8 | org2 | NULL | NULL | 5 |
+----+------+------+-------------+------+
这里是向数据表中添加两个父机构及其子机构,这种情况,异常为:

HTTP Status 500 -

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /org/index.jsp at line 105
102: ${org.sn }
103:
104:


105: ${org.parent.name}
106:
107:
108: Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
root cause
javax.el.ELException: Error reading 'name' on type com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca
javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:274)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:218)
org.apache.jsp.org.index_jsp._jspService(index_jsp.java:165)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
root cause
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.oa.model.Orgnization#0]
org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375)
org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)
com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca.getName()
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:274)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:218)
org.apache.jsp.org.index_jsp._jspService(index_jsp.java:165)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

[b]问题补充:[/b]
mysql> select * from t_orgnization;
+----+------+------+-------------+------+
| id | name | sn | description | pid |
+----+------+------+-------------+------+
| 1 | org1 | NULL | NULL | NULL |
| 2 | org4 | NULL | NULL | 1 |
| 3 | org3 | NULL | NULL | 1 |
| 4 | org2 | NULL | NULL | 1 |
+----+------+------+-------------+------+
4 rows in set (0.00 sec)
这里是向数据表中添加一个父机构和3个子机构,这种情况没问题。
mysql> select * from t_orgnization;
+----+------+------+-------------+------+
| id | name | sn | description | pid |
+----+------+------+-------------+------+
| 1 | org1 | NULL | NULL | NULL |
| 2 | org4 | NULL | NULL | 1 |
| 3 | org3 | NULL | NULL | 1 |
| 4 | org2 | NULL | NULL | 1 |
| 5 | org1 | NULL | NULL | NULL |
| 6 | org4 | NULL | NULL | 5 |
| 7 | org3 | NULL | NULL | 5 |
| 8 | org2 | NULL | NULL | 5 |
+----+------+------+-------------+------+
这里是向数据表中添加两个父机构及其子机构,这种情况,异常为:

HTTP Status 500 -

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /org/index.jsp at line 105
102: ${org.sn }
103: </td>
104: <td align="center" vAlign="center">
105: ${org.parent.name}
106: </td>
107: <td align="center" vAlign="center">
108: <a href="#"
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
root cause
javax.el.ELException: Error reading 'name' on type com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca
javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:274)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:218)
org.apache.jsp.org.index_jsp._jspService(index_jsp.java:165)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
root cause
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.oa.model.Orgnization#0]
org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375)
org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)
com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca.getName(<generated>)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:274)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:218)
org.apache.jsp.org.index_jsp._jspService(index_jsp.java:165)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "
http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


name="com.cenc.infopublish.model.Organization">












[b]问题补充:[/b]
mysql> select * from t_orgnization;
+----+------+------+-------------+------+
| id | name | sn | description | pid |
+----+------+------+-------------+------+
| 1 | org1 | NULL | NULL | NULL |
| 2 | org4 | NULL | NULL | 1 |
| 3 | org3 | NULL | NULL | 1 |
| 4 | org2 | NULL | NULL | 1 |
+----+------+------+-------------+------+
4 rows in set (0.00 sec)
这里是向数据表中添加一个父机构和3个子机构,这种情况没问题。
mysql> select * from t_orgnization;
+----+------+------+-------------+------+
| id | name | sn | description | pid |
+----+------+------+-------------+------+
| 1 | org1 | NULL | NULL | NULL |
| 2 | org4 | NULL | NULL | 1 |
| 3 | org3 | NULL | NULL | 1 |
| 4 | org2 | NULL | NULL | 1 |
| 5 | org1 | NULL | NULL | NULL |
| 6 | org4 | NULL | NULL | 5 |
| 7 | org3 | NULL | NULL | 5 |
| 8 | org2 | NULL | NULL | 5 |
+----+------+------+-------------+------+
这里是向数据表中添加两个父机构及其子机构,这种情况,异常为:

HTTP Status 500 -

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /org/index.jsp at line 105
102: ${org.sn }
103: </td>
104: <td align="center" vAlign="center">
105: ${org.parent.name}
106: </td>
107: <td align="center" vAlign="center">
108: <a href="#"
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
root cause
javax.el.ELException: Error reading 'name' on type com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca
javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:274)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:218)
org.apache.jsp.org.index_jsp._jspService(index_jsp.java:165)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
root cause
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.oa.model.Orgnization#0]
org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375)
org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)
com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca.getName(<generated>)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:274)
org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:218)
org.apache.jsp.org.index_jsp._jspService(index_jsp.java:165)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class table="T_Organization"
name="com.cenc.infopublish.model.Organization">
<id name="id">
<generator class="native" />
</id>
<property name="name" />
<property name="sn" />
<property name="description" />
<many-to-one column="pid" name="parent" />
<set lazy="false" inverse="true" name="children">
<key column="pid" />
<one-to-many class="com.cenc.infopublish.model.Organization" />
</set>
</class>
</hibernate-mapping>

[b]问题补充:[/b]
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


name="com.cenc.infopublish.model.Organization">













[b]问题补充:[/b]

试过了,这种方式还是行不通!!
[b]问题补充:[/b]
package com.cenc.infopublish.model;

import java.util.Set;

/**

  • @author Administrator
    */
    public class Organization {

    private Integer id;

    private String name;

    private String sn;

    private String description;

    private Organization parent;

    private Set children;

    public Set getChildren() {
    return children;
    }

    public void setChildren(Set children) {
    this.children = children;
    }

    public String getDescription() {
    return description;
    }

    public void setDescription(String description) {
    this.description = description;
    }

    public Integer getId() {
    return id;
    }

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

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public Organization getParent() {
    return parent;
    }

    public void setParent(Organization parent) {
    this.parent = parent;
    }

    public String getSn() {
    return sn;
    }

    public void setSn(String sn) {
    this.sn = sn;
    }

    @Override
    public String toString() {
    return "id=" + id;
    }

}

[b]问题补充:[/b]
action:

public class OrgAction extends BaseAction {

private OrgManager orgManager;

/**
 * 打开机构管理主界面
 */
@Override
protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    OrgActionForm oaf = (OrgActionForm) form;

    request.setAttribute("pm", orgManager.findOrgs(oaf.getParentId()));

    PagerModel pm = orgManager.findOrgs(oaf.getParentId());

    int ppid = 0;
    if (oaf.getParentId() != 0) {
        Organization org = orgManager.findOrg(oaf.getParentId());
        Organization parent = org.getParent();
        if (parent != null) {
            ppid = parent.getId();
        }
    }

    request.setAttribute("ppid", ppid);

    if (oaf.isSelect()) {
        return mapping.findForward("select");
    }

    return mapping.findForward("index");
}

}

public class OrgManagerImpl extends AbstractManager implements OrgManager {
public PagerModel findOrgs(int parentId) {

    // 如果parentId=0,则查找顶级机构列表
    if (parentId == 0) {
        return searchPaginated("from Organization o where o.parent is null");
    }
    return searchPaginated("from Organization o where o.parent.id = ?",
            parentId);
}

}

public class AbstractManager extends HibernateDaoSupport {
public PagerModel searchPaginated(String hql){
return searchPaginated(hql,null,SystemContext.getOffset(),SystemContext.getPagesize());

public PagerModel searchPaginated(String hql,Object[] params,int offset,int pagesize){

    //获取记录总数
    String countHql = getCountQuery(hql);
    Query query = getSession().createQuery(countHql);
    if(params != null && params.length > 0){
        for(int i=0; i<params.length; i++){
            query.setParameter(i, params[i]);
        }
    }
    int total = ((Long)query.uniqueResult()).intValue();

    //获取当前页的结果集
    query = getSession().createQuery(hql);
    if(params != null && params.length > 0){
        for(int i=0; i<params.length; i++){
            query.setParameter(i, params[i]);
        }
    }

    query.setFirstResult(offset);
    query.setMaxResults(pagesize);
    List datas = query.list();

    PagerModel pm = new PagerModel();
    pm.setTotal(total);
    pm.setDatas(datas);
    return pm;
}

/**
 * 根据HQL语句,获得查找总记录数的HQL语句
 * 如:
 * select ... from Orgnization o where o.parent is null
 * 经过转换,可以得到:
 * select count(*) from Orgnization o where o.parent is null
 * @param hql
 * @return
 */
private String getCountQuery(String hql){
    int index = hql.indexOf("from");
    if(index != -1){
        return "select count(*) " + hql.substring(index);
    }

    throw new SystemException("无效的HQL查询语句!");
}

}
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • mccxj 小毛1983 13年前

    ${org.parent.name}

    怎么没看到页面是如何去到org对象的

    点赞 评论 复制链接分享
  • mccxj 小毛1983 13年前

    那请贴出页面说引用到的对象相关的代码。

    点赞 评论 复制链接分享
  • mccxj 小毛1983 13年前

    试试

    点赞 评论 复制链接分享
  • mccxj 小毛1983 13年前

    javax.el.ELException: Error reading 'name' on type com.oa.model.Orgnization$$EnhancerByCGLIB$$ec9313ca

    org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.oa.model.Orgnization#0]
    org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:375)

    请检查org是否合法

    用hibernate,请贴出xml配置

    点赞 评论 复制链接分享

相关推荐