3
我User
模型類是傳統的爲以下各項找不到布爾吸氣休眠
package org.ravij.model;
public class User {
private String username;
private String password;
private boolean isAdmin;
public boolean isAdmin() {
return isAdmin;
}
public void setAdmin(boolean isAdmin) {
this.isAdmin = isAdmin;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
我得到異常下面,而與休眠運行它v4.2-
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for isAdmin in class org.ravij.model.User
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:316)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310)
at org.hibernate.mapping.Property.getGetter(Property.java:321)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:436)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:200)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:82)
以下是hibernate映射配置文件 -
<hibernate-mapping package="org.ravij.model">
<class name="User" table="Users">
<id name="username" type="string" column="User_Name" length="20">
<generator class="assigned" />
</id>
<property name="password" type="string" column="Password" />
<property name="isAdmin" column="Admin" type="boolean" />
</class>
</hibernate-mapping>
爲什麼我得到錯誤"Could not find a getter for boolean"
以及需要做什麼更改?
它的工作......非常感謝你......你能給我提供關於'JavaBean命名約定'的更多細節嗎?任何文檔? – 2013-03-26 21:01:51
http://www.google.com/?q=javabean+naming+convention;) – NilsH 2013-03-26 21:15:07
好吧...我對javabean的命名約定和命名慣例跟hibernate有點困惑。謝謝 – 2013-03-27 08:17:27