Given this code:
Criteria crit = s.createCriteria(CorrespondenceRecipient.class) .createCriteria(CorrespondenceRecipient.CORRESPONDENCE_PARENT, JoinType.NONE).add(Restrictions.eq(Base.CLASSTYPE, EMail.class)) .setProjection(Projections.id());
results in an
2014-04-02 09:29:18,858 DEBUG [main] (SqlStatementLogger.java:109) - select base1_.id as y0_ from p_corr_recipients this_ inner join jaf_base_entities this_1_ on this_.id=this_1_.id where base1_.classType=? 2014-04-02 09:29:18,859 WARN [main] (SqlExceptionHelper.java:144) - SQL Error: 1054, SQLState: 42S22 2014-04-02 09:29:18,859 ERROR [main] (SqlExceptionHelper.java:146) - Unknown column 'base1_.id' in 'field list'
but
Criteria crit = s .createCriteria(CorrespondenceRecipient.class) .createAlias(CorrespondenceRecipient.CORRESPONDENCE_PARENT, "go", JoinType.NONE).add(Restrictions.eq(Base.CLASSTYPE, EMail.class)).setProjection(Projections.id());
properly creates an 2014-04-02 09:30:33,104 DEBUG [main] (SqlStatementLogger.java:109) - select this_.id as y0_ from p_corr_recipients this_ inner join jaf_base_entities this_1_ on this_.id=this_1_.id where this_1_.classType=?
even though the alias is not used.
I need JoinType.None here because the parent has a joined inheritance that hits the maximum table limit when it is queried without specifying a subclass.
|