在main方法里 可以通过 主表 查询到 字表
但放到action里 页面上找不到子表的字段,控制台也打印出了信息
POJO类 get set方法省略
[code="java"]
主表的pijo
private Integer id;
private String password;
private String names;
private Set ta2s = new HashSet();
字表的pojo
private Integer id;
private String kecheng;
private Integer ids;
private Ta1 ta1;
[/code]
[size=x-small]Action里的方法[/size]
[code="java"]
public ActionForward lists(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response) throws Exception{
Query query = getSession().createQuery("from Ta1 ");
List list = query.list();
request.setAttribute("views", list);
return mapping.findForward("lis");
}
[/code]
hbm配置文件
[code="java"]
<set name="ta2s" cascade="all" lazy="false" inverse="true">
<key column="ids"> </key>
<one-to-many class="org.test.dao.Ta2"/>
</set>
<many-to-one name="ta1" insert="false" lazy="false" update="false" class="org.test.dao.Ta1">
<column name="ids"> </column>
</many-to-one>
[/code]
jsp页面
[code="java"]
${st.names}
${st.kecheng}
href="">
src="img_files/del.gif" border=0>
href="">
src="img_files/edit.gif" border=0>
</TR>
</c:forEach>
</c:when>
<c:otherwise>
<%response.sendRedirect(request.getContextPath()+"/view.do?method=lists"); %>
</c:otherwise>
</c:choose>
[/code]
异常信息
[code="java"]
javax.servlet.jsp.el.ELException: Unable to find a value for "kecheng" in object of class "org.test.dao.Ta1" using operator "."
org.apache.commons.el.Logger.logError(Logger.java:481)
org.apache.commons.el.Logger.logError(Logger.java:498)
org.apache.commons.el.Logger.logError(Logger.java:611)
org.apache.commons.el.ArraySuffix.evaluate(ArraySuffix.java:340)
org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:899)
org.apache.jsp.list_jsp._jspx_meth_c_forEach_0(list_jsp.java:228)
org.apache.jsp.list_jsp._jspx_meth_c_when_0(list_jsp.java:191)
org.apache.jsp.list_jsp._jspService(list_jsp.java:120)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
[/code]
控制台打印出来的信息
控制台打印出来的show_sql
select ta1x0_.id as id4_, ta1x0_.password as password4_, ta1x0_.names as names4_ from test_ssh.ta1 ta1x0_
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
Hibernate: select ta2s0_.ids as ids1_, ta2s0_.id as id1_, ta2s0_.id as id5_0_, ta2s0_.kecheng as kecheng5_0_, ta2s0_.ids as ids5_0_ from test_ssh.ta2 ta2s0_ where ta2s0_.ids=?
[b]问题补充:[/b]
就是想叫它找到 kecheng 这个字段啊,怎么找呢?
[b]问题补充:[/b]
问题就是 怎么找出Ta2表里的 kecheng啊