Hibernate - PropertyNotFoundException: Could not find a getter for

后端 未结 10 1683
一个人的身影
一个人的身影 2020-12-10 13:53

I have a class that looks like the following:

public class MyClass {
    private String dPart1;

    public String getDPart1() {
        return dPart1;
    }         


        
相关标签:
10条回答
  • 2020-12-10 14:11

    The naming convention of the property matters example in my own case I initially used

    private String newimsi, getNewImsi();
    

    the above failed with same exception

    propertynotfoundexception

    until I corrected to below before it worked

    getNewimsi();
    
    0 讨论(0)
  • 2020-12-10 14:15
    <property name="DPart1" not-null="true"/>
    

    should work...

    0 讨论(0)
  • 2020-12-10 14:17

    Can't you just access it like a field?

    access="field"

    0 讨论(0)
  • 2020-12-10 14:18

    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.

    0 讨论(0)
  • 2020-12-10 14:19

    From what I've seen, Hibernate (at least version 3.2.4) will expect a property like dPart to have a getter named getdPart: d stays lowercase. Look at dfa's answer as well - I am guessing that other versions might expect getDpart instead.

    0 讨论(0)
  • 2020-12-10 14:21
    private String rptausu;
    
    public String getRptausu() {
        return rptausu;
    }
    
    public void setRptausu(String rpta) {
        rptausu = rpta;
    }
    

    mapping:

            <property name="prtausu" />
    

    works correctly

    0 讨论(0)
提交回复
热议问题