gpt4 book ai didi

java - 组织.hibernate.PropertyNotFoundException : could not find getter for customerId in class Address

转载 作者:行者123 更新时间:2023-11-29 08:06:11 24 4
gpt4 key购买 nike

我的地址类:

public class Address  implements java.io.Serializable {
private String addressId;
private String customerId;

public Address() {
}

public Address(String addressId) {
this.addressId = addressId;
}
public Address(String addressId, String customerId) {
this.addressId = addressId;
this.customerId = customerId;

public String getAddressId() {
return this.addressId;
}

public void setAddressId(String addressId) {
this.addressId = addressId;
}
public String getCustomerId() {
return this.customerId;
}

public void setCustomerId(String customerId) {
this.customerId = customerId;
}

我的 hbm.xml 文件:

<class name="Address" table="Address">
<id name="addressId" column="address_id" type="java.lang.String">
<generator class="assigned" />
</id>

<property name="customerId" column="customer_id" type="java.lang.String" />

</class>

出现以下错误

org.hibernate.PropertyNotFoundException: Could not find a getter for customerId in class Address
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)

最佳答案

Hibernate 在大写方面可能有点棘手。

尝试将 CustomerId 作为属性名称,一切都应该没问题。如果您将属性命名为 customerID

,Hibernate 需要一个 getcustomerId 方法

关于java - 组织.hibernate.PropertyNotFoundException : could not find getter for customerId in class Address,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11045372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com