-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Alias not working in DetachedCriteria
PostPosted: Thu May 17, 2007 9:10 am 
Beginner
Beginner

Joined: Tue Apr 24, 2007 12:53 pm
Posts: 28
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.