用SSH框架开发 如何在hibernate层实现多表查询
publicListfindByShopId(java.lang.IntegerSHOPID){System.out.println("已经进入DAO");try{Str...
public List findByShopId(java.lang.Integer SHOPID) {
System.out.println("已经进入DAO");
try {
String queryString = "from SsjFood as model where model.shopId=? order by model.foodPrice";
return getHibernateTemplate().find(queryString, SHOPID);
} catch (RuntimeException re) {
// TODO: handle exception
System.out.println("ooooo");
throw re;
}
}
-------------------------------------------------------------------------------------|
单表查询是这个样子 那么多表查询呢 为什么我下面这个写法不行
-------------------------------------------------------------------------------------------
public List searchfood(String foodname){
try {
String queryString =" from SsjFood sf ,SsjShop ss where sf.shopID=ss.shop_ID and model.foodName like '%"+foodname+"%'";
System.out.println("hello search food");
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
// TODO: handle exception
System.out.println("searchfood DAO error !1");
throw re;
}
} 展开
System.out.println("已经进入DAO");
try {
String queryString = "from SsjFood as model where model.shopId=? order by model.foodPrice";
return getHibernateTemplate().find(queryString, SHOPID);
} catch (RuntimeException re) {
// TODO: handle exception
System.out.println("ooooo");
throw re;
}
}
-------------------------------------------------------------------------------------|
单表查询是这个样子 那么多表查询呢 为什么我下面这个写法不行
-------------------------------------------------------------------------------------------
public List searchfood(String foodname){
try {
String queryString =" from SsjFood sf ,SsjShop ss where sf.shopID=ss.shop_ID and model.foodName like '%"+foodname+"%'";
System.out.println("hello search food");
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
// TODO: handle exception
System.out.println("searchfood DAO error !1");
throw re;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询