I am getting the unable to resolve property: username
I can't figure it out please help.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="jrnl">
<class name="com.philip.journal.core.bean.User" table="USER" schema="jrnl">
<meta attribute="class-description">
Represents a user of the Journal Application.
</meta>
<id name="username" type="string" length="16" access="field">
<generator class="assigned" />
</id>
<property name="password" column="PASSWORD" type="string" not-null="false" length="128" />
<property name="checksum" column="CHECKSUM" type="string" not-null="false" length="128" />
<many-to-one class="com.philip.journal.core.bean.User" fetch="select" name="creator" column="CREATE_ID"
property-ref="username" not-found="ignore" />
<many-to-one class="com.philip.journal.core.bean.User" fetch="select" name="updater" column="UPDATE_ID"
property-ref="username" not-found="ignore" />
<property name="createDate" type="date">
<column name="CREATE_DATE" length="13" not-null="false" />
</property>
<property name="createTime" type="time">
<column name="CREATE_TIME" length="21" not-null="false" />
</property>
<property name="updateDate" type="date">
<column name="UPDATE_DATE" length="13" not-null="false" />
</property>
<property name="updateTime" type="time">
<column name="UPDATE_TIME" length="21" not-null="false" />
</property>
<filter name="patchFilter" condition="1=1" />
</class>
<query name="user.userByUsername">
from User as user
where user.username = :username
</query>
<filter-def name="patchFilter" />
</hibernate-mapping>
My java bean
Code:
package com.philip.journal.core.bean;
import com.philip.journal.core.exception.JournalRuntimeException;
/**
* Represents a user of the Journal Application.
*
* This bean is tied with spring hibernate. Will disallow setting the username from the client code.
*/
public class User extends AuditableBean {
private String username;
private String password;
private String checksum;
public User() {
}
public User(String username) {
this.username = username;
}
public User(String username, String password, String checksum) {
this.username = username;
this.password = password;
this.checksum = checksum;
}
public String getUsername() {
return this.username;
}
/**
* @param username
* @exception JournalRuntimeException
* - this should never be set by client.
*/
public void setUsername(String username) {
this.username = username;
/*
* if (Thread.currentThread().getStackTrace()[6].getClassName().indexOf(
* "org.hibernate.property.BasicPropertyAccessor$BasicSetter") > -1) { this.username = username; } else { throw
* new JournalRuntimeException("Illegal access to protected object", null); }
*/}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getChecksum() {
return this.checksum;
}
public void setChecksum(String checksum) {
this.checksum = checksum;
}
@Override
public String getPrimaryKeyField() {
return "username";
}
}