在main方法里 可以通过 主表 查询到 字表 但放到action里 页面上找不到子表的字段 Action里的方法
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"); }
hbm配置文件
<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>
jsp页面
<c:choose>
<c:when test="${views!=null}">
<c:forEach items="${views}" var="st" >
<TR class=web_td1>
<TD align=middle><br>${st.names}<br></TD>
<TD align=left>
<center>${st.ids}</center>
</TD>
<TD align=middle>
<A
href=""><IMG
src="img_files/del.gif" border=0>
</A>
</TD>
<TD align=middle>
<A
href=""><IMG
src="img_files/edit.gif" border=0>
</A>
</TD>
</TR>
</c:forEach>
</c:when>
<c:otherwise>
<%response.sendRedirect(request.getContextPath()+"/view.do?method=lists"); %>
</c:otherwise>
</c:choose>异常信息: Unable to find a value for "kecheng" in object of class "org.test.dao.Ta1" using operator "."
控制台打印出来的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=?
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"); }
hbm配置文件
<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>
jsp页面
<c:choose>
<c:when test="${views!=null}">
<c:forEach items="${views}" var="st" >
<TR class=web_td1>
<TD align=middle><br>${st.names}<br></TD>
<TD align=left>
<center>${st.ids}</center>
</TD>
<TD align=middle>
<A
href=""><IMG
src="img_files/del.gif" border=0>
</A>
</TD>
<TD align=middle>
<A
href=""><IMG
src="img_files/edit.gif" border=0>
</A>
</TD>
</TR>
</c:forEach>
</c:when>
<c:otherwise>
<%response.sendRedirect(request.getContextPath()+"/view.do?method=lists"); %>
</c:otherwise>
</c:choose>异常信息: Unable to find a value for "kecheng" in object of class "org.test.dao.Ta1" using operator "."
控制台打印出来的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=?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货