Hi, persistence guys~
During testing persistence examples through orm.xml, I got error regarding
property access type.
The entity class has no annotations, all mappings are declared in orm.xml.
The access type is declared as PROPERTY explicitly.
public class Person implements java.io.Serializable {
String _name;
String _address;
public Person(){
}
public Person(String name){
this._name = name;
}
public String getName() {
return _name;
}
public void setName(String name) {
this._name = name;
}
public String getAddress() {
return _address;
}
public void setAddress(String address) {
this._address = address;
}
public String toString(){
return "Person: {"+"(name = "+_name +", address = " + _address +
")}";
}
}
<?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_1_0.xsd" version="1.0">
<entity name="Person" class="
com.sun.s1asdev.ejb.ejb30.persistence.ormdesc.par.Person" access="PROPERTY"
>
<table name="EJB30_PERSISTENCE_DESC_PERSON"/>
<attributes>
<id name="name">
<column name="NAME"/>
</id>
<basic name="address">
<column name="ADDRESS"/>
</basic>
</attributes>
</entity>
</entity-mappings>
When I deploy the application following error occurs.
Exception [TOPLINK-7216] (Oracle TopLink Essentials - 2006.4 (Build
060420)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot determine the type (class) of attribute [name]
in entity class [com.sun.s1asdev.ejb.ejb30.persistence.ormdesc.par.Person].
Internal Exception: java.lang.NoSuchFieldException: name
at
oracle.toplink.essentials.exceptions.ValidationException.unableToDetermineClassForAttribute
(ValidationException.java:1666)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataHelper.getClassForAttribute(
MetadataHelper.java:206)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLAccessor.getRelationType(
XMLAccessor.java:326)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLAccessor.getReferenceClass(
XMLAccessor.java:314)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLAccessor.isEmbedded(
XMLAccessor.java:550)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAccessor(
MetadataProcessor.java:505)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.EntityMappingsXMLProcessor.processAttributes
(EntityMappingsXMLProcessor.java:1068)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.EntityMappingsXMLProcessor.processEntityNode(
EntityMappingsXMLProcessor.java:1413)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.EntityMappingsXMLProcessor.processEntities
(EntityMappingsXMLProcessor.java:1313)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.EntityMappingsXMLProcessor.processEntityMappings(
EntityMappingsXMLProcessor.java:1501)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.processEntityMappingsXML
(EntityManagerSetupImpl.java:534)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(
EntityManagerSetupImpl.java:398)
at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory
(EntityManagerFactoryProvider.java:145)
at com.sun.enterprise.server.PersistenceUnitLoaderImpl.load (
PersistenceUnitLoaderImpl.java:195)
at com.sun.enterprise.server.PersistenceUnitLoaderImpl.load(
PersistenceUnitLoaderImpl.java:77)
at com.sun.enterprise.server.AbstractLoader.loadPersistenceUnits(
AbstractLoader.java :849)
at com.sun.enterprise.server.ApplicationLoader.load(
ApplicationLoader.java:179)
It seems to me that MetadataHelper.getClassForAttribute() has some
assumption - corresponding field exists for the attribute. So it does
Class.getField() to identify the type of attribute. I think it is incorrect
assumption in this entity case.
I attach test sources, it can be unzipped into
appserv-tests/devtests/ejb/ejb30/persistence and run as other tests.
If this is a bug, it seems to me serious bug - very basic behaviour though
descriptor fails....-.-;
Regards,
Wonseok Kim