Tag: 多对多的

如何动态地订购与JPA或HQL的多对多关系?

我有这样的映射: @ManyToMany(cascade = CascadeType.PERSIST) @JoinTable( name=”product_product_catalog”, joinColumns={@JoinColumn(name=”product_catalog”, referencedColumnName=”product_catalog”)}, inverseJoinColumns={@JoinColumn(name=”product”, referencedColumnName=”product”)}) public List products = new ArrayList(); 我可以很好地获取目录的产品,但我不能(动态)订购产品。 我怎么能订购它们? 我可能必须使用order-by子句编写多对多的HQL查询? 我虽然将orderBy字段名称字符串传递给查询,还是有更好的解决方案? 表是:products,product_catalog,product_product_catalog(associative table) PS使用播放! 我的实体的框架JPASupport。