-->
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: Multiple level Property in Criteria
PostPosted: Tue May 24, 2005 8:24 pm 
Regular
Regular

Joined: Mon Apr 25, 2005 9:22 am
Posts: 62
Location: Bucharest/Romania
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,


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 8:33 pm 
Regular
Regular

Joined: Mon Apr 25, 2005 9:22 am
Posts: 62
Location: Bucharest/Romania
For the moment it seems that it is working only if the 2nd level property is not an entity at its own. Is this statement true?


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.