我正在使用Java RESTLET编写REST服务。
我的用户类在这里:
@Entity
@Table(name = "user")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "idUser", nullable = false, unique = true, length = 255)
private Long idUser;
@Column(name = "name", nullable = true, length = 255)
private String name;
@Column(name = "username", nullable = false, length = 255)
private String username;
@Column(name = "password", nullable = false, length = 255)
private String password;
public Object setValue(Object input) {
Object fieldValue = ((input == null) ? JSONObject.NULL.toString()
: input);
return fieldValue;
}
public String getUserPassword() {
return password;
}
public void setUserPassword(String password) {
this.password = password;
}
public String getUserName() {
return username ;
}
public void setUserName(String userName) {
this.username = userName;
}
public Long getidUser() {
return idUser;
}
public void setIdUser(Long idUser) {
this.idUser = idUser;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContactFirstName() {
return contactFirstName;
}
public void setContactFirstName(String contactFirstName) {
this.contactFirstName = contactFirstName;
}
public String getContactLastName() {
return contactLastName;
}
public void setContactLastName(String contactLastName) {
this.contactLastName = contactLastName;
}
public String getContactEmail() {
return contactEmail;
}
public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}
public String getContactMobile() {
return contactMobile;
}
public void setContactMobile(String contactMobile) {
this.contactMobile = contactMobile;
}
public String getContactPhone() {
return contactPhone;
}
public void setContactPhone(String contactPhone) {
this.contactPhone = contactPhone;
}
public String getContactAddress() {
return contactAddress;
}
public void setContactAddress(String contactAddress) {
this.contactAddress = contactAddress;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Timestamp getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Timestamp createdDate) {
this.createdDate = createdDate;
}
public Timestamp getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(Timestamp updatedDate) {
this.updatedDate = updatedDate;
}
}
我的User.hbm.xml文件看起来像。
<?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>
<class name="persistence.entity.User" table="user">
<id name="idUser" type="long" unsaved-value="null">
<column name="idUser" not-null="true"/>
<generator class="identity"/>
</id>
<property name="userName">
<column name="username" not-null="true" />
</property>
<property name="password">
<column name="password" not-null="true" />
</property>
<property name="status">
<column name="status" not-null="true" />
</property>
<property name="type">
<column name="type" not-null="true" />
</property>
<property name="createdDate">
<column name="createdDT" not-null="true" />
</property>
<property name="updatedDate">
<column name="updatedDT" not-null="false" />
</property>
<property name="name">
<column name="name" length="255" not-null="false" />
</property>
<property name="contactFirstName">
<column name="contactFirstName" length="255" not-null="false" />
</property>
<property name="contactLastName">
<column name="contactLastName" length="255" not-null="false" />
</property>
<property name="contactEmail">
<column name="contactEmail" length="255" not-null="false" />
</property>
<property name="contactMobile">
<column name="contactMobile" length="32" not-null="false" />
</property>
<property name="contactPhone">
<column name="contactPhone" length="32" not-null="false" />
</property>
<property name="contactAddress">
<column name="contactAddress" not-null="false" />
</property>
</class>
</hibernate-mapping>
我已经在我的User.java文件中定义了getter ans setter。
但是当我运行此代码时,我收到错误
Could not find a getter for password in class tecd.persistenc.entity.User
我不知道我错过了什么PLZ帮帮我
答案 0 :(得分:1)
您已为此password
声明了getter和setter:
public String getUserPassword() {
return password;
}
public void setUserPassword(String password) {
this.password = password;
}
我认为它应该是这样的(不是&#34;用户&#34;在其中):
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
这些是password
字段的标准&#34; bean&#34;式名称。