I tried to upgrade from Castor 0.9.5.2 to 0.9.5.3 today, but my code would
no longer compile because the code that was generated from my schema is
different. My (slightly watered-down) schema is given below. The gist of it
is as follows:

1) I have a main element called "table" that has a list of "mapped-field"
elements and a list of "derived-field" elements.

2) "mapped-field" and "derived-field" are defined as extensions of a common
element ("field") which defines some common attributes.

3) My intention is to generate a base class "Field" and two subclasses
"MappedField" and "DerivedField" that extend "Field".

What I am finding is that the Field, MappedField, and DerivedField classes
are being generated correctly, but the generated accessor methods in the
Table class end up being defined as:

  Object[] getMappedField() and Object[] getDerivedField()

instead of

  MappedField[] getMappedField() and DerivedField[] getDerivedField()

Trying to cast the results of these methods to MappedField[] or
DerivedField[] generates a ClassCastException. I can't figure out whether
this change is intentional (i.e. some change in functionality with the new
version) or a bug. Any advice would be appreciated.

Regards,

Jim Doble
Tavve Software Company


<?xml version="1.0"?>

<schema xmlns="http://www.w3.org/2001/XMLSchema";>

  <element name="table">
    <complexType>
      <sequence>
        <element name="mapped-field" minOccurs="0" maxOccurs="unbounded" />
        <element name="derived-field" minOccurs="0" maxOccurs="unbounded" />
      </sequence>
    </complexType>
  </element>

  <complexType name="field">
    <attribute name="clientName" type="string" use="required" />
    <attribute name="clientType" type="string" use="required" />
    <attribute name="size" type="int" use="optional" />
  </complexType>

  <element name="mapped-field">
    <complexType>
      <complexContent>
        <extension base="field">
          <attribute name="serverName" type="string" use="required" />
          <attribute name="serverType" use="required" />
        </extension>
      </complexContent>
    </complexType>
  </element>

  <element name="derived-field">
    <complexType>
      <complexContent>
        <extension base="field">
          <sequence>
            <element ref="is-null" minOccurs="0" maxOccurs="1" />
            <element ref="not-null" minOccurs="0" maxOccurs="1" />
          </sequence>
        </extension>
      </complexContent>
    </complexType>
  </element>

  <element name="is-null">
    <complexType>
      <attribute name="serverName" type="string" use="required" />
    </complexType>
  </element>

  <element name="not-null">
    <complexType>
      <attribute name="serverName" type="string" use="required" />
    </complexType>
  </element>

</schema>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to