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.