Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate - PropertyNotFoundException: Could not find a getter for

Tags:

java

hibernate

I have a class that looks like the following:

public class MyClass {
    private String dPart1;

    public String getDPart1() {
        return dPart1;
    }

    public void setDPart1(String dPart1) {
        this.dPart1 = dPart1;
    }
}

My hibernate mapping file maps the property as follows:

<property name="dPart1" not-null="true"/>

I get the following error:

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 

It appears that hibernate doesn't like my capitalization. How should I fix this?

like image 419
Ben Noland Avatar asked May 28 '09 14:05

Ben Noland


2 Answers

<property name="DPart1" not-null="true"/>

should work...

like image 138
Fortega Avatar answered Oct 25 '22 17:10

Fortega


Can't you just access it like a field?

access="field"

like image 28
Rune Sundling Avatar answered Oct 25 '22 18:10

Rune Sundling