tags:

views:

3146

answers:

8

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?

+5  A: 
<property name="DPart1" not-null="true"/>

should work...

Fortega
I am also facing the problem and the above solutions works fine for me.Now what I would like to know is is it java specification for setter getter methods or is it jboss specific implementation for hibernate?Thank you for your answer :)
Vineyard
+1  A: 

for a property called "dPart1" a hibernate will try a getter named "getDpart1" not "getDPart1" IIRC

dfa
+2  A: 

Can't you just access it like a field?

access="field"

Rune Sundling
A: 

I am facing same problem.

A: 

I got the solution

Please make dPart1 to dpart1 and change the getter and setter again..

It is working for me now.

Remember to change the xml also.

A: 

Umesh Aqwte is right. I got the solution

A: 

So, no camelcasing for property names. :(

Ananth
A: 
private String rptausu;

public String getRptausu() {
    return rptausu;
}

public void setRptausu(String rpta) {
    rptausu = rpta;
}

mapping:

        <property name="prtausu" />

works correctly

JuserNt