@Entity
@Table(name = "goods")
public class Goods {
private String id;
private String name;
private String description;
private Double price;
private String yuanjia;
private Date createDate;
private Date modifyDate;
..........................................
@NamedQueries( { @NamedQuery(name = "getUserOrder", query = "from OrderDetail o where o.user.id=? order by createDate desc") })
@Entity
public class OrderDetail {
private String id;
private List<OrderDetailItem> orderDetailItem = new ArrayList<OrderDetailItem>();
..............................................
@Entity
@Table(name = "orderdetailitem")
public class OrderDetailItem {
private static final long serialVersionUID = 1L;
private String id;
private Goods goods = new Goods();
private Integer num;
private OrderDetail orderDetail;
///
public class GeneralVO2{
private String id;
private String name;
private Double price;
private int num;
public GeneralVO2(String id, String name, Double price, int num) {
super();
this.id = id;
this.name = name;
this.price = price;
this.num = num;
}
public List<OrderDetailItem> getOrderDetailItem(OrderDetail orderDetail) {
//查询语句一
String JPQL = "select new org.ncist.evaaass.qsl.vo.GeneralVO2 (o.orderDetail.id,o.goods.name,o.goods.price,o.num) "
+ " from "
+ OrderDetailItem.class.getSimpleName()
+ " o where o.orderDetail.id ='"
+ orderDetail.getId() + "'";
//查询语句二
/*String JPQL = "select o.id,o.orderDetailItem.goods.name,o.orderDetailItem.goods.price,o.orderDetailItem.num"
+ " from "
+ OrderDetail.class.getSimpleName()
+ " o where o.id='"
+ orderDetail.getId() + "'";*/
List list=dao.getByJQL(JPQL, 0, 400);
return list;
}