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 > 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:
|
|