I am trying to use a multiple level Property defined as:
Code:
Property.forName("application").getProperty("database").getProperty("id")
or
Code:
Property.forName("application.database.id")
and i am getting an exception: org.hibernate.QueryException: could not resolve property: application.database of: com.ez.ezrt.model.ApplicationAccess
Hibernate version: 3.0.4
Mapping documents:Code:
<class name="View"
table="APPVIEW"
mutable="false"
batch-size="10">
<id name="id"
column="ID"
type="java.lang.Long"
unsaved-value="0">
<generator class="identity"/>
</id>
<property name="viewname"
type="java.lang.String"
column="viewName"
length="100"
unique="true"
not-null="true" />
<many-to-one name="application" class="Application">
<column name="ID_APP" not-null="true" />
</many-to-one>
</class>
<class name="Application"
table="APPLICATION"
mutable="false">
<id name="id"
column="ID"
type="java.lang.Long"
unsaved-value="0">
<generator class="identity"/>
</id>
<property name="appname"
type="java.lang.String"
column="applicationName"
length="100"
not-null="true"/>
<property name="oid"
type="java.lang.Long"
column="ID_ORIGINAL"
not-null="true"/>
<many-to-one name="database" class="ITDatabase">
<column name="ID_IT" not-null="true"/>
</many-to-one>
</class>
<class name="ITDatabase"
table="ITDATABASE"
mutable="true"
batch-size="10"
polymorphism="explicit">
<meta attribute="extends">LiteITDatabase</meta>
<id name="id"
type="java.lang.Long"
column="ID"
unsaved-value="0">
<generator class="identity" />
</id>
</class>
Code between sessionFactory.openSession() and session.close():Code:
session.createCriteria(View.class)
.add(Property.forName("application")
.getProperty("database")
.getProperty("id")
.eq(new Long(1))
)
.setProjection(Projections.property("application.id"))
.list();
Full stack trace of any exception that occurs:Code:
org.hibernate.QueryException: could not resolve property: application.database of: com.ez.ezrt.model.View
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:402)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:368)
at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:42)
at org.hibernate.criterion.Junction.toSqlString(Junction.java:58)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:313)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:81)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1301)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
Name and version of the database you are using:
HSQLDB 1.7.3.3
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
tia,