把代码都贴上来吧。如果要查询product列表,sql语句应该类似于select * from Product where com_id=?,如果在ProductHibDAO实现,方法应该类似于findList(CompanyBean com)怎么会是findByExample(Product instance)呢?至于hql,where后的参数换成<many-to-one>中的配置就行了,这样的问题可以看看hibernate文档。
解决方案 »
- 两个问题,如何:tomcat的url不区分大小写,MyEclipse调试时查看临时表示式的值
- strus标签中怎么得到子表中的字段值?
- BMC有关SOL
- mssql中float字段映射到hibernate如果写
- struts+spring+hibernate问题
- Hibernate 数据映射问题 (50分,在线等)
- 请问高手们该如何学习java的类库!
- 我的TOMCAT与APACHE已经整合成功,但JSP运行出错,在线等!急
- XML数据插入到Oracle中乱码:在线急待。。谢谢!
- 怎样关闭J2EE?
- glassfish真是庞大
- tomcat 在exclips中联机调试,项目中新修改的部分在运行时似乎看不出来
public List findByExample(Product instance) {
log.debug("finding Product instance by example");
try {
List results = new ArrayList();
// 按条件默认查询
Criteria criteria = getSession().createCriteria( "com.daqin.gridouter.data.vo.Product").add(Example.create(instance));
results = criteria.list(); return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}ProductBO中的方法如下:
public List getProductDefault(){ ProductBean product = new ProductBean();
CompanyBean company = new CompanyBean();
company.setId("001");
product.setCompany(company); List defaultList = this.getProductDAO().findByExample(product);
return defaultList;
}