一個getter我有一個類,如下所示:休眠 - PropertyNotFoundException:找不到
public class MyClass {
private String dPart1;
public String getDPart1() {
return dPart1;
}
public void setDPart1(String dPart1) {
this.dPart1 = dPart1;
}
}
我的Hibernate映射文件映射屬性,如下所示:
<property name="dPart1" not-null="true"/>
我得到的以下錯誤:
org.hibernate.PropertyNotFoundException: Could not find a getter for dPart1 in class com.mypackage.MyClass
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.mapping.Property.getGetter(Property.java:272)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:302)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at
看起來,hibernate不喜歡我的大寫。我應該如何解決這個問題?
我也面臨這個問題,上述解決方案對我來說工作正常。 現在我想知道的是它是setter getter方法的java規範,還是它是針對hibernate的jboss特定實現? 謝謝您的回答:) – 2009-11-15 06:44:08
您能否提供關於您解決方案的解釋? – Marco 2016-09-13 15:14:26