Hopefully I'm understanding how the alias is supposed to work. Consider the following:
Code:
ProjectionList pl1 = Projections.projectionList();
DetachedCriteria c = criteriaExport.createCriteria("PrcsSet", "Prcs");
c.setProjection(pl1.add(Projections.property("Jobs.".concat(Jobs.PROP_ID))).add(
Projections.property("Jobs.".concat(Jobs.FILE_NME))).add(
Projections.property("Jobs.".concat(Jobs.CUST_ID))).add(
Projections.property("Jobs.".concat(Jobs.CLNT_ID))).add(
Projections.property("Jobs.".concat(Jobs.FIL_CAT))).add(
Projections.property("Jobs.".concat(Jobs.FIL_TYP))).add(
Projections.property("Jobs.".concat(Jobs.JOB_NME)))
);
c.add(Expression.eq("Jobs.".concat(Jobs.CUST_ID), expCriteria.getCustId()));
c.add(Expression.eq("Jobs.".concat(Jobs.CLNT_ID), expCriteria.getClntId()));
c.add(Expression.eq("Jobs.".concat(Jobs.FIL_CAT), expCriteria.getFileCat()));
c.add(Expression.eq("Jobs.".concat(Jobs.PRCS_TYP), Constants.PRCS_TYP));
c.add(Expression.eq("Prcs.".concat(Prcs.PRCS_SQNCE), Constants.PRCS_SQNCE)));
List resultList = c.getExecutableCriteria(session).list()
This code keeps throwing the following exception:
Code:
org.hibernate.QueryException: could not resolve property: Prcs of: com.mypackage.hibernate.Prcs
Now, if i remove the "Prcs." alias in the last Criteria add() method. It works just fine.
If i use the DetachedCriteria.createAlias() method instead of the createCriteria() method. It also works perfectly fine.
My question is: Shouldn't the current form of this code work just fine also? Based on what I thought I knew of Hibernate, the alias should be used when joining the second table to the first. Therefore i should be able to reference using the alias defined.
Thoughts as to why this may not be working...? Bug or i'm just off my rocker this morning...
-B[/code]