个人Hibernate笔记:两张表多对一映射以后,如何查出一表里面的数据?

版权声明:转载请标注来源:https://me.csdn.net/qq_37844454 https://blog.csdn.net/qq_37844454/article/details/83153389

项目有两张表:应用类型表1,应用表2,两张表已经用Hibernate映射了,之前都是通过类型Id相对应的应用Id,现在要通过应用Id来查询与之对应的类型Id,如何做呢?

由于之前一直没有用过这样的查询方式,自己胡乱鼓捣以后,终于得出了方法,如下:

 <%
	for (int y = 0; y < appList.size(); y++) {
		CustomerApplication n = (CustomerApplication) appList.get(y);
	     AppType a = n.getAppType();
		%>
		<a href="%=n.getCustomerAppName()%>/<%=n.getCustomerId()%>/
            <%=a.getId()%>">%=n.getCustomerAppName()%></a>
	<%
	}
	%>

效果如下:

就这样吧。

猜你喜欢

转载自blog.csdn.net/qq_37844454/article/details/83153389