Spring Framework 3.2.8中的org.eclipse.persistence.exceptions.ValidationException

时间:2015-06-29 08:14:07

标签: java spring-mvc jpa

将此类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.

1 个答案:

答案 0 :(得分:3)

已修复!

std::map<int64_t, int64_t> foo;
boost::filesystem::path myFile = boost::filesystem::current_path() / "myfile.dat";

if (filesystem::exists(myFile))
{
    filesystem::ifstream ifs(myFile/*.native()*/);
    archive::text_iarchive ta(ifs);

    ta >> foo; // foo is empty until now, it's fed by myFile

    std::cout << "Read " << foo.size() << " entries from " << myFile << "\n";
} else {
    for (int i=0; i<100; ++i) foo[i] = 10;
    filesystem::ofstream ofs(myFile/*.native()*/);
    archive::text_oarchive ta(ofs);

    ta << foo; // foo is empty until now, it's fed by myFile
    std::cout << "Wrote " << foo.size() << " random entries to " << myFile << "\n";
}