product_template, product_account, product_style and product_account are tables. mysql command:
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 command is working fine but I don't know how to implement in criteria.
My code:
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();
Iam getting only id's of product_account but I need id's of product_template. Any would be appreciated. Thanks in advance.