Hibernate - PropertyNotFoundException: Could not find a getter for

后端 未结 10 1684
一个人的身影
一个人的身影 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:28

    For a property private Integer carId;

    the setters and getters should be

    getCarId() setCarId(Integer carId)

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

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

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

    The setter & getter should look like this

    getdPart1()
    setdPart1(....)
    

    That's how the setters & getters are generated if generated through an IDE like eclipse.

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

    Best Practice is not to create getters/setters by our self but use the Eclipse Shortcut(Alt+Shift+S) to create the same for the variables defined in a bean/pojo.

    Naming convention does matters.

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