product_template、product_account、product_style、product_account はテーブルです。mysql コマンド:
select distinct product_template.id as ptid from product_account inner join product on product_account.productId=product.id inner join product_style on product.productStyleId=product_style.id inner join product_template on product_style.productTemplateId=product_template.id where product_account.sellerId=1 and product_account.productAccountType=1;
Mysql コマンドは正常に動作していますが、基準に実装する方法がわかりません。
私のコード:
Criteria c = createCriteria(ProductAccount.class);
ProjectionList projectionList = Projections.projectionList();
c.add(Restrictions.eq("seller", query.getSeller()));
c.add(Restrictions.eq("productAccountType", query.getProductAccountType()));
c.createCriteria("product").createCriteria("productStyle").createCriteria("productTemplate");
c.setProjection(Projections.distinct(Projections.property("id")));
List<Object> objects = c.list();
product_account の ID しか取得できませんが、product_template の ID が必要です。いずれかをいただければ幸いです。前もって感謝します。