Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.id=product.id inner join product_style on product.id=product_style.id inner join product_template on product_style.id=product_template.id where product_account.sellerId=1 and product_account.productAccountType=0;

Mysql command is working fine but I don't know how to implement in criteria.
My code:

Criteria c = createCriteria();
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.

share|improve this question
can you post the pojo class implementations – Sanjaya Liyanage 35 mins ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.