【问题标题】:org.eclipse.persistence.exceptions.ValidationException in Spring Framework 3.2.8Spring Framework 3.2.8 中的 org.eclipse.persistence.exceptions.ValidationException
【发布时间】:2015-09-15 15:05:34
【问题描述】:

让这个类AddressInfo带有一个内部类Coordinate我在部署时出错:“没有定义相应的setter方法”,但是定义了setter方法!

@SuppressWarnings("serial")
@Entity
@Immutable
@Table(name = "T_ADDRESS_INFO")
public class AddressInfo implements java.io.Serializable {

    public class Coordinate {

        double latitude;
        double longitude;

        Coordinate(int latitude, int longitude) {
            this.latitude = latitude;
            this.longitude = longitude;
        }

        public double getLatitude() {
            return latitude;
        }

        public void setLatitude(double latitude) {
            this.latitude = latitude;
        }

        public double getLongitude() {
            return longitude;
        }

        public void setLongitude(double longitude) {
            this.longitude = longitude;
        }
    }


    private Long id;
    private String street;
    private String address;
    private String code;
    private String city;
    private String phone;
    private String fax;
    private String email;
    private String website;
    private String info;
    private String latitude;
    private String longitude;

    public AddressInfo() {
    }

...

}

我在部署时遇到此错误

Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The getter method [method getLatitude] on entity class [class AddressInfo] does not have a corresponding setter method defined.

【问题讨论】:

    标签: java spring-mvc jpa


    【解决方案1】:

    已修复!

    @SuppressWarnings("serial")
    @Entity
    @Immutable
    @Table(name = "T_ADDRESS_INFO")
    public class AddressInfo implements java.io.Serializable {
    
    
        public class Coordinate {
    
            double latitude;
            double longitude;
    
            Coordinate(int latitude, int longitude) {
                this.latitude = latitude;
                this.longitude = longitude;
            }
    
            @Column(name = "LATITUDE")
            public double getLatitude() {
                return latitude;
            }
    
            public void setLatitude(double latitude) {
                this.latitude = latitude;
            }
    
            @Column(name = "LONGITUDE")
            public double getLongitude() {
                return longitude;
            }
    
            public void setLongitude(double longitude) {
                this.longitude = longitude;
            }
        }
    
        private Long id;
        private String street;
        private String address;
        private String code;
        private String city;
        private String phone;
        private String fax;
        private String email;
        private String website;
        private String info;
    
    
        public AddressInfo() {
        }
    

    【讨论】:

      猜你喜欢
      • 2017-12-15
      • 1970-01-01
      • 2016-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      • 2017-02-01
      相关资源
      最近更新 更多