我使用的是Hibernate 3.6,JPA 2.0和Spring 3.0.6。我在我的对象,如以下字段:在Hibernate/JPA中,字段名称是否以单个字母驼峰开头?
class PersonContact {
Long eAddressCpId;
ElectronicAddress eAddress;
}
我使用字段访问(在我的ORM文件)和查询/插入/等工作没有问题。这些字段既在类中,也在orm文件中。但在应用程序的启动,JPA配置负载吐出警告:
2011-02-22 15:38:10,785 [[STANDBY] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader - Property com.foo.model.contactpoint.ElectronicAddress.eAddress not found in class but described in (possible typo error) 2011-02-22 15:38:10,801 [[STANDBY] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader - Property com.foo.model.person.PersonContact.eAddressCpId not found in class but described in (possible typo error) 2011-02-22 15:38:10,801 [[STANDBY] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader - Property com.foo.model.person.PersonContact.eAddress not found in class but described in (possible typo error) 2011-02-22 15:38:10,817 [[STANDBY] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader - Property com.foo.model.person.PartyContact.eAddressCpId not found in class but described in (possible typo error) 2011-02-22 15:38:10,817 [[STANDBY] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader - Property com.foo.model.person.PartyContact.eAddress not found in class but described in (possible typo error)
如果我改变我的字段名是electronicAddressCpId和electronicAddress,然后我没有得到这些警告。
围绕字段名称有要求吗?
谢谢.jay
---------附加信息--------------------------- ----- 这是我的POJO片段。
/**
* This is a generated class. Do not modify.
*/
@XmlRootElement(namespace = "http://foo.com/model", name = "ElectronicAddress")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://foo.com/model", name = "ElectronicAddress", propOrder = { "eAddress", "id" })
public class ElectronicAddress extends ContactPoint {
/**
* The serialize value.
*/
private static final long serialVersionUID = -1L;
/**
* The eAddress field.
*/
@XmlElement(name = "EAddress", namespace = "##default")
private String eAddress;
/**
* The id field.
*/
@XmlElement(name = "Id", namespace = "##default")
private Long id; //NOPMD
/**
* Gets the value of the eAddress property.
* This field is Required.
*
* @return eAddress object is {@link String }
*/
public String getEAddress() {
return eAddress;
}
/**
* Sets the value of the eAddress property.
* This field is Required
*
* @param eAddress object is {@link String }
*/
public void setEAddress(String eAddress) {
this.eAddress = eAddress;
}
/**
* Gets the value of the id property.
* This field is Optional.
*
* @return id object is {@link Long }
*/
public Long getId() {
return id;
}
/**
* Sets the value of the id property.
* This field is Optional
* genericInheritGetterSetter
* @param id object is {@link Long }
*/
public void setId(Long id) {
this.id = (Long) id;
}
}
这是一个orm文件的片段。
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<description>com.foo.model.ElectronicAddress Entity Mapping</description>
<package>com.foo.model</package>
<schema>COMMON</schema>
<access>FIELD</access>
<entity class="com.foo.model.ElectronicAddress"
access="FIELD" metadata-complete="true">
<table name="ELECTRONIC_ADDRESSES" />
<attributes>
<id name="id">
<column name="ELECTRONIC_ADDRESS_ID" />
<generated-value strategy="SEQUENCE" generator="ADDR_SEQ" />
<sequence-generator name="ADDR_SEQ"
sequence-name="COMMON.ADDR_SEQ" allocation-size="1" />
</id>
<basic name="eAddress">
<column name="ELECTRONIC_ADDRESS" />
</basic>
</attributes>
</entity>
</entity-mappings>
我花了相当多的时间来回应,但这绝对不是我们在生产中运行时的错字,所有Hibernate持久化都能成功运行,而且orm文件是由代码生成的,而不是开发人员操纵的,我们只是获取这些消息(每个以小写字母开头的字段至少大约60+)。此外,我没有使用注释,我使用HBM文件......这是否有差异。 – 2012-01-25 20:16:40