persistence@glassfish.java.net

Re: property acess type error in orm.xml descriptor

From: Guy Pelletier <guy.pelletier_at_oracle.com>
Date: Wed, 3 May 2006 09:53:27 -0400

Great!

As for the field error, could you file another bug to have it corrected?

Thanks,
Guy
  ----- Original Message -----
  From: Wonseok Kim
  To: persistence_at_glassfish.dev.java.net
  Sent: Tuesday, May 02, 2006 11:19 PM
  Subject: Re: property acess type error in orm.xml descriptor


  I updated GF and it works well. Great!

  When I didn't specify access type at all, then it seems that property access type is default. right?

  In other way, I tested with FIELD access type again like below but it failed.

      <entity name="Person" class="com.sun.s1asdev.ejb.ejb30.persistence.ormdesc.par.Person" access="FIELD" >
          <table name="EJB30_PERSISTENCE_DESC_PERSON"/>
          <attributes>
              <id name="_name">
                  <column name="NAME"/>
              </id>
              <basic name="_address">
                  <column name="ADDRESS"/>
              </basic>
          </attributes>
      </entity>

  There is incorrect constants for FIELD access type in XMLConstants class.
  FIELD should have "FIELD" string as orm_1_0.xsd.
  So in above test "FIELD" attribute is not processed well and the default access type property is used.

  public class XMLConstants {
      // miscellaneous values
      public static final String FIELD = "field";
     //...
     static final String PROPERTY = "PROPERTY";

  Thanks,
  Wonseok



  On 5/3/06, Guy Pelletier <guy.pelletier_at_oracle.com> wrote:
    Sahoo,

    There was an internal bug filed here. The fix was made to our source and it
    is being included in the next persistence drop.

    Cheers,
    Guy

    ----- Original Message -----
    From: "Sanjeeb Kumar Sahoo" < Sanjeeb.Sahoo_at_Sun.COM>
    To: <persistence_at_glassfish.dev.java.net>
    Sent: Tuesday, May 02, 2006 10:58 AM
    Subject: Re: property acess type error in orm.xml descriptor


> Guy,
>
> Do you know the bug id of this *serious* bug?
>
> Thanks,
> Sahoo
> Guy Pelletier wrote:
>> Wonseok,
>> This is a known issue and it has been corrected and will be submitted to
>> CVS today.
>> Cheers,
>> Guy
>>
>> ----- Original Message -----
>> *From:* Wonseok Kim <mailto:guruwons_at_gmail.com >
>> *To:* persistence_at_glassfish.dev.java.net
>> <mailto:persistence_at_glassfish.dev.java.net >
>> *Sent:* Tuesday, May 02, 2006 10:32 AM
>> *Subject:* property acess type error in orm.xml descriptor
>>
>> 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
>>
>