-->
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.  [ 3 posts ] 
Author Message
 Post subject: could not resolve property
PostPosted: Tue Jun 26, 2007 11:31 am 
Newbie

Joined: Tue Jun 26, 2007 10:37 am
Posts: 5
Hello everyone, I got this org.hibernate.QueryException:could not resolve property: ......and could not figure out the problem.

This is the UserApp.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.wu.wads.model">
   <class name="com.wu.wads.model.UserApp" table="USRAPP" dynamic-update="true"  optimistic-lock="version">
      <meta attribute="class-description">
         Represents a UserApp for the WASD web site.
         @author trungu
      </meta>
      <meta attribute="implement-equals">true</meta>
      <meta attribute="implement-tostring">true</meta>
      <composite-id class="com.wu.wads.model.UserApp">
         <key-property name="userId" type="string" column="USER_ID"
            length="16">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
         </key-property>
         <key-property name="acctId" type="string" column="ACCT_ID"
            length="10">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
         </key-property>
         <key-property name="appId" type="string" column="APP_ID"
            length="10">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
         </key-property>
      </composite-id>
   </class>
</hibernate-mapping>

and the UserApp bean:

Code:
public class UserApp implements Serializable {
   private String userId;
   private String acctId;
   private String appId;
..
....
   /**
    * @return the acctId
    */
   public String getAcctId() {
      return acctId;
   }

   /**
    * @param acctId the acctId to set
    */
   public void setAcctId(String acctId) {
      this.acctId = acctId;
   }

   /**
    * @return the appId
    */
   public String getAppId() {
      return appId;
   }

   /**
    * @param appId the appId to set
    */
   public void setAppId(String appId) {
      this.appId = appId;
   }

   /**
    * @return the userId
    */
   public String getUserId() {
      return userId;
   }

   /**
    * @param userId the userId to set
    */
   public void setUserId(String userId) {
      this.userId = userId;
   }
..
....


and the implementation code:
Code:
public class LogonDAOHibernate extends HibernateDaoSupport implements LogonDAO {
..
.....
   public User findUsrAndCltId(UserDTO userDTO) {
..
....
      String query = "from com.wu.wads.model.UserApp uA where uA.userId = ? and uA.acctId = ?";
      String usrId = userDTO.getUserId().trim();
      String clientId = userDTO.getAcctId().trim();
      Object[] parameters = { usrId, clientId };
      List list = this.getHibernateTemplate().find(query, parameters);
..
....



and the spring config file
Code:
...
.......
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
         <ref local="dataSource"/>
      </property>
      <property name="mappingResources">
         <list>
            <value>com/wu/wads/model/User.hbm.xml</value>
            <value>com/wu/wads/model/UserApp.hbm.xml</value>
...
.......


I checked at the UserApp bean many times to find if there's a typo...
The thing is the User.hbm.xml is OK, I am able to find the record in the USER table, but with the UserApp, I got this exception:
Code:
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: userId of: com.wu.wads.model.UserApp [from com.wu.wads.model.UserApp uA where uA.userId = ? and uA.acctId = ?]; nested exception is org.hibernate.QueryException: could not resolve property: userId of: com.wu.wads.model.UserApp [from com.wu.wads.model.UserApp uA where uA.userId = ? and uA.acctId = ?]


Any ideas would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 3:17 pm 
Newbie

Joined: Tue Jun 26, 2007 10:37 am
Posts: 5
I resolved the issue and just in case someone has the same problem, here is what I did: eliminate the class attribute in the composite-id element.
Code:
Old
      <composite-id class="com.wu.wads.model.UserApp>
         <key-property name="userId" type="string" column="USER_ID"
            length="16">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
....
.......

New
      <composite-id>
         <key-property name="userId" type="string" column="USER_ID"
            length="16">
            <meta attribute="use-in-equals">true</meta>
            <meta attribute="use-in-tostring">true</meta>
....
.......



Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 3:51 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
Just to add a bit of explanation:

class attribute is required if there is a class representing the composite id and the class being mapped has a getter and setter for the object mentioned in class.

Regards,
Jitendra


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.