0

I have an entity called ServiceList that has set of productListOrders

 @Entity
 @Table(name="service_lists")
 public class ServiceList implements Serializable {
private static final long serialVersionUID = 1L;
    private Set<ProductServiceListOrder> productServiceListOrders = new HashSet<ProductServiceListOrder>();
}

ProductServiceListOrder looks like this 
public class ProductServiceListOrder implements Serializable {
private static final long serialVersionUID = 1L;

private ServiceList serviceList;
private Product product;
private Date createdAt;

private Long id;
private Integer internalOrder;
}

The trick is in internalOrder which the highest internalOder value showed first .. when I do my hibernate query I do like this ...

{
List<ServiceList> lists = (List<ServiceList>) JPA.em().createQuery(
                    "select  distinct list from com.vionlabs.movieoncloud.model.main.ServiceList list " +
                            "left join fetch list.productServiceListOrders "  )
}

MY QUESTION IS :- I want to set a limit on left join that means I want to get only the highest 10 productSeriveListOrders when I do the query ... How I can do this .... any suggestions ?

4

1 に答える 1

0

メソッドによって返されたQueryオブジェクトに対して、メソッドを使用し、これをクエリの order by と組み合わせて使用​​できます。createQueryentityManagersetMaxResult

于 2013-02-26T18:45:36.417 に答える