-->
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.  [ 2 posts ] 
Author Message
 Post subject: Excption with order by : could not resolve property
PostPosted: Tue Oct 11, 2005 5:50 am 
Newbie

Joined: Tue Oct 11, 2005 4:53 am
Posts: 1
We select objects of type EvaluationFunction and up till now we only ordered these objects on columns proper to this table. Now a new requirement entered and the elements of the Evaluationfunction table must be ordered by a field of a foreign key field. Obviously this did not work too well.

We added code bit in case if refers to a foreign key :

property = property + "." + criteria.getDisplayProfForSelect();

in our case this gives dg.acronym.

Probably since this is not in the select clause this throws an exception. Is there a workaround or easy solution avoiding a join?

Regards,

Marc

Hibernate version:
3.0

Mapping documents:

<class
name="cec.budg.eims.model.EvaluationFunction"
table="T_EVAL_FUNCTION"
lazy="false"
dynamic-update="true"
dynamic-insert="true"
where=" end_Validity_Date &gt; sysdate"
>
<cache usage="read-write" />

<id
name="id"
column="ID"
type="java.lang.Integer"
>

<many-to-one
name="dg"
class="cec.budg.eims.model.DirectoriteGeneral"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="DG_ID"
not-null="true"
/>

.............. etc.
</class>

<class
name="cec.budg.eims.model.DirectoriteGeneral"
table="T_GEN_DG"
lazy="false"
dynamic-update="true"
dynamic-insert="true"
where="VALID_FLG='T'"
>
<cache usage="read-only" />

<id
name="id"
column="ID"
type="java.lang.Integer"
>

<property
name="acronym"
type="java.lang.String"
update="true"
insert="true"
column="ACRONYM"
length="100"
/>

</class>


Code between sessionFactory.openSession() and session.close():

We use spring and for session control

public Object doInHibernate(Session session) throws HibernateException {

System.out.println(criteriaMap.toString());

Criteria criteria = session.createCriteria(myClass);
if (criteriaMap != null) {
HibernateCriteriaParser parser = new HibernateCriteriaParser(
criteria);
parser.parseCriteriaArray(criteriaMap);
}
criteria.setProjection(Projections.rowCount());
criteria.setFirstResult(0);
criteria.setMaxResults(1);
int total = ((Integer) criteria.uniqueResult()).intValue();
System.out.println("Full size : " + total);

criteria = session.createCriteria(myClass);
if (criteriaMap != null) {
HibernateCriteriaParser parser = new HibernateCriteriaParser(
criteria);
parser.parseCriteriaArray(criteriaMap);
}

int calculatedIndex;
if (startIndex > 0) {
calculatedIndex = startIndex;

} else {
calculatedIndex = (Math.round((total - 1) / blockSize) * blockSize) + 1;
}

if (criteriaMap != null) {
HibernateCriteriaParser parser = new HibernateCriteriaParser(
criteria);
parser.parseCriteriaArray(criteriaMap);
}
System.out.println(" FR:[" + calculatedIndex + "] MR : ["
+ blockSize + "]");
criteria.setFirstResult(calculatedIndex - 1);
criteria.setMaxResults(blockSize);
Collection coll = criteria.list();
System.out.println("Collection size : " + coll.size());

ResultCollection resultCollection = new ResultCollection();
resultCollection.addAll(coll);

resultCollection.setFullRowCount(total);
resultCollection.setCurrentIndex(calculatedIndex);

return resultCollection;



Full stack trace of any exception that occurs:

asc:dg.acronym
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: dg.acronym of: cec.budg.eims.mod
el.EvaluationFunction; nested exception is org.hibernate.QueryException: could not resolve property: dg.acronym of: cec.
budg.eims.model.EvaluationFunction
org.hibernate.QueryException: could not resolve property: dg.acronym of: cec.budg.eims.model.EvaluationFunction
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43
)
at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:63)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31)
at org.hibernate.persister.entity.BasicEntityPersister.toColumns(BasicEntityPersister.java:1086)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:403)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:
369)
at org.hibernate.criterion.Order.toSqlString(Order.java:36)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getOrderBy(CriteriaQueryTranslator.java:326)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:81)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1303)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:433)
at cec.budg.persistence.dao.AbstractDaoHibImpl$SearchByCriteriaHibernateCallback.doInHibernate(AbstractDaoHibImp
l.java:153)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:288)
at cec.budg.persistence.dao.AbstractDaoHibImpl.searchByCriteria(AbstractDaoHibImpl.java:115)
at cec.budg.eims.dao.EvaluationFunctionDaoHibImpl.searchByCriteria(EvaluationFunctionDaoHibImpl.java:59)
at cec.budg.eims.proxy.EvaluationFunctionProxyDao.searchByCriteria(EvaluationFunctionProxyDao.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:288)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:163)
at $Proxy17.searchByCriteria(Unknown Source)
at cec.budg.ejb.session.facade.eims.EvaluationFunctionFacadeEJB.searchByCriteria(EvaluationFunctionFacadeEJB.jav
a:137)
at cec.budg.ejb.session.facade.eims.EvaluationFunctionFacade_t40vc1_EOImpl.searchByCriteria(EvaluationFunctionFa
cade_t40vc1_EOImpl.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.remoting.rmi.RmiClientInterceptorUtils.doInvoke(RmiClientInterceptorUtils.java:98)
at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.doInvoke(SimpleRemoteSlsbInvokerInterceptor
.java:75)
at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.invoke(AbstractRemoteSlsbInvokerIntercept
or.java:114)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy9.searchByCriteria(Unknown Source)
at cec.budg.web.eims.action.EvaluationFunctionSearchAction.getResultCollection(EvaluationFunctionSearchAction.ja
va:179)
at cec.budg.web.action.BudgSearchAction.setDataInRequest(BudgSearchAction.java:57)
at cec.budg.web.action.BudgSearchAction.SEARCH_BUTTON_CLICKED(BudgSearchAction.java:165)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:276)
at cec.budg.web.action.BudgDispatchAction.dispatchMethod(BudgDispatchAction.java:119)
at cec.budg.web.action.BudgDispatchAction.execute(BudgDispatchAction.java:85)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at cec.budg.web.ecas.EcasLocalGroupFilter.doFilter(EcasLocalGroupFilter.java:59)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6724)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

Name and version of the database you are using:

Oracle 8.1

The generated SQL (show_sql=true):

Well we do not even get to generate an hql. Befor we arrive at generating t the hql the crash occurs.

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 3:07 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
u will need to use aliases if you want to order on a association property.


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

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.