Shipment类
private String id;
private String shipmentdate;
private String kehuName;
private String sellName;
private Set<ShipmentProduct> shipmentProducts=new HashSet<ShipmentProduct>(0);shipmentproduct类
private String product_id;
private Shipment shipment;
private String productName;
private String productSerial;
private String alwaysSerial;
private String ybSerial;
private String checker;
private String grade;
private String dytSerial;
private String qdSerial;
private String software;
private String re;
两者是一对多的关系。Dao层实现代码
public List findYBBydate(String startDate, String endDate) {
Session session=HibernateSessionFactory.getSession();
Query query=session.createSQLQuery("select * from shipment s,shipment_product sp where s.id=sp.shipmentid and s.shipmentdate between ? and ? and sp.yb_serial is not null");
query.setString(0,startDate);
query.setString(1,endDate);
return query.list();
}目前能从dao层中能获得一个list集合对象,怎样获得shipment和shipmentproduct类中的属性?
private String id;
private String shipmentdate;
private String kehuName;
private String sellName;
private Set<ShipmentProduct> shipmentProducts=new HashSet<ShipmentProduct>(0);shipmentproduct类
private String product_id;
private Shipment shipment;
private String productName;
private String productSerial;
private String alwaysSerial;
private String ybSerial;
private String checker;
private String grade;
private String dytSerial;
private String qdSerial;
private String software;
private String re;
两者是一对多的关系。Dao层实现代码
public List findYBBydate(String startDate, String endDate) {
Session session=HibernateSessionFactory.getSession();
Query query=session.createSQLQuery("select * from shipment s,shipment_product sp where s.id=sp.shipmentid and s.shipmentdate between ? and ? and sp.yb_serial is not null");
query.setString(0,startDate);
query.setString(1,endDate);
return query.list();
}目前能从dao层中能获得一个list集合对象,怎样获得shipment和shipmentproduct类中的属性?
解决方案 »
- struts2 Action类中构造方法问题
- ueditor上传图片失败,请大神指点!
- xdoclet & ant & hibernate 无法生成指定数据库中的表
- 如何让<a>标签的字当获得焦点时改变颜色
- 怎么配置CVS服务器
- hibernate struts2做项目出的问题
- 给领导提的关于WEB开发模式的建议,请大家看看在什么水平上,有没有必要提出来?
- 调试jsp时进不了servlet
- 如何有些网站用jsp+ Servlet开发手机发短信息,这是如何开发的?哪里有参考书?
- 关于j2ee文件上传出现的问题
- VB刚学,哪位老师帮忙指教。有哪方面的知识要加强学习的?有哪方面的书籍推荐?记得回帖,先谢过啦!
- JSP页面的值如何放入到Rquest中
把Shipment类和shipmentproduct类
属性加进去,如果重复的只要一个就行了!
这样可以不?
((Object[])list.get(i))[0]--->shipment
((Object[])list.get(i))[1]--->shipment_product
你可以使用相似的语句:("from shipment_product sp where sp.shipment.shipmentdate between ? and ? and sp.yb_serial is not null"); 这样出来就只有shipment_product 了,你就可以使用((shipment_product)(list.get(i)))来读取相关属性了....如果是用EL,也就更容易了
sp.shipment.xxxx
sp.xxx