Hibernate Create Criteria to join the same table twice - tried 2 approach with 2 difference error
I would like to create create criteria for the following native sql. Unfortunately, I hit error of duplicate associate path when use createCriteria twice. When I try to use Restrictions.sqlRestriction. It unable provide the SQL that I want. Try 1: Create Criteria - duplicate associate path Criteria criteria = getSession().createCriteria( Company.class ); criteria.createAlias( "customerCategories", "c1" ); criteria.add( Restrictions.in( "c1.customerCategory.customerCategoryId", company.getBaseCustomerCategoryId() ) ); criteria.createAlias( "customerCategories", "c2" ); criteria.add(