Hi Paul,
Yes, please file a bug report on this, and if you can attach your test case, that would be great. Thanks, --Keith Paul Grillo wrote: > > Well, it looks to me that there is a bug in the XML Mapping. I haven't > been able to solve it. Don't know if anybody had a look at the previous > post. > > As succinctly as I can. If you have class B which has an identity which > extends A (in java), and another class C has a collection of these (Bs) > by reference, then if the mapping file explicitly calls out for B > extends="A", > > You get this error when marshalling: > " Unable to resolve ID for instance of class 'B' > due to the following error: No identity descriptor available" > > If you change the mapping file such that B does not extend A, and place > A's mapping elements in B, the problem goes away. > > So this is my workaround. I'd prefer to not duplicate mapping elements > in my mapping file, preferring to make use of extends. Luckily I only > have a couple of places where I've got a collection of these by > reference. > > Would somebody like me to package up a test harness for reproduction? > Shall I log it as a bug? > > Thanks > > -----Original Message----- > From: Paul Grillo > Sent: Thursday, March 11, 2004 9:48 PM > To: castor-dev > Subject: [castor-dev] XML Mapping - Problems using identity and extends. > > Can't get past it. Relates to use of identity and a Base class from > which I derive all classes. > > This is a continuation of a mapping excercise i started a week ago. I > am using RC2 version of Castor for the purposes of marshaling a map of > Integer/Address Object. > > With keith's help, i got the Map working by insuring that the collection > of objects preceded the references. > > Now as i move forward and add a few items i'm finding that i'm getting > problems when i mix extended classes with identity. > > Problem statement. > > I basically have 4 objects > > Party (abstract class) contains a Mapped collection of Addresses > by Reference > Business (derived from Party) > Address (contains address information) > > I was able to get this to work properly, but now i have introduced a > base class for all of the above obects > called "BusinessObject" It is very small, has only 2 or 3 methods. > > So, now Party and Address are derived from BusinessObject > > Below is a mapping file that works. Notice that i do not specify that > Address is derived from BusinessObject and I place the 2 fields of > interest in Address Mapping that is defined in BusinessObject. > > Everything works fine. But as soon as I add > extended="com.trivin.bo.BusinessObject" to Address (and remove the > fields related to BusinessObject) thus virtually making no logical > change to it i get the following error: > > Unable to resolve ID for instance of class 'com.trivin.bo.party.Address' > due to the following error: No identity descriptor available > > ---Mapping File that Works---- > <?xml version="1.0"?> > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version > 1.0//EN" > "http://castor.exolab.org/mapping.dtd"> > > <mapping> > <!-- *********************************** Business Object (the super > Object) ********************** --> > <class name="com.trivin.bo.BusinessObject" auto-complete="true"> > <!-- ************* Exclude > *************************************** --> > <field name="BOFactory" get-method="getBOFactory" > type="com.trivin.bo.BOFactory" transient="true" /> > <!-- > ************************************************************** --> > > <field name="productID" type="integer" > > <bind-xml name="productID" node="attribute" /> > </field> > </class> > > <!-- *********************************** Party ********************** > --> > <class name = "com.trivin.bo.party.Party" > extends="com.trivin.bo.BusinessObject" identity="castorHashCode" > auto-complete="true"> > > <!-- ************* Exclude > *************************************** --> > <field name="addressRoles" type="integer" > get-method="getAddressRoles" collection="array" transient="true" /> > <field name="partyType" type="integer" transient="true" > /> > <field name="partyID" type="long" transient="true" /> > <field name="business" type="boolean" transient="true" > /> > <field name="individual" type="boolean" > transient="true" /> > <field name="name" type="string" transient="true" /> > <!-- > ************************************************************** --> > <field name="castorHashCode" type="integer" > > <bind-xml name="key" node="attribute" /> > </field> > <field name="suspensionViolation" type="string" > > <bind-xml name="suspensionViolation" node="attribute" > /> > </field> > <field name="suspensionState" type="string" > > <bind-xml name="suspensionState" node="attribute" /> > </field> > <field name="phone" type="string" > > <bind-xml name="phone" node="attribute" /> > </field> > <field name="dmvId" type="string" > > <bind-xml name="dmvId" node="attribute" /> > </field> > <field name="FAX" type="string" > > <bind-xml name="FAX" node="attribute" /> > </field> > <field name="jurisdiction" type="string" > > <bind-xml name="Jurisdiction" node="attribute" /> > </field> > <!-- End Map of Address References --> > <field name="castorAddresses" > type="com.trivin.bo.party.Address" > collection="array" > > <bind-xml name="Address" location="Addresses"/> > </field> > <!-- Hashmap of with key as Role and Value as Address --> > <field name="addressMap" > type="org.exolab.castor.mapping.MapItem" > collection="map" > get-method="getAddressMap" > set-method="setAddressMap" > > <bind-xml> > <class name= > "org.exolab.castor.mapping.MapItem"> > <field name="key" type="integer"> > <bind-xml name="role" node = > "attribute"/> > </field> > <field name="value" > type="com.trivin.bo.party.Address"> > <bind-xml name="Address" > node="element" reference="true" /> > </field> > </class> > </bind-xml> > </field> > </class> > <!-- *********************************** Business ********************** > --> > <class name="com.trivin.bo.party.Business" > extends="com.trivin.bo.party.Party" auto-complete="true"> > <field name="name" type="string"> > <bind-xml name="Name" node="attribute"/> > </field> > <field name="doingBusinessAs" type="string" > > <bind-xml name="DBA" node="attribute" /> > </field> > <field name="feidNumber" type="string" > > <bind-xml name="FEIDNumber" node="attribute" /> > </field> > </class> > <!-- *********************************** Individual > ********************** --> > <class name="com.trivin.bo.party.Individual" > extends="com.trivin.bo.party.Party" auto-complete="true"> > <!-- ************* Exclude > *************************************** --> > <field name="eyeColor" type="string" transient="true" /> > <field name="birthDateString" type="string" > transient="true" /> > <!-- > ************************************************************** --> > > <field name="birthDate" type="date" > > <bind-xml name="birthDate" node="attribute" /> > </field> > <field name="irpExempt" type="string" > > <bind-xml name="irpExempt" node="attribute" /> > </field> > <field name="prefix" type="string" > > <bind-xml name="prefix" node="attribute" /> > </field> > <field name="firstName" type="string" > > <bind-xml name="firstName" node="attribute" /> > </field> > <field name="middleName" type="string" > > <bind-xml name="middleName" node="attribute" /> > </field> > <field name="lastName" type="string" > > <bind-xml name="lastName" node="attribute" /> > </field> > <field name="suffix" type="string" > > <bind-xml name="suffix" node="attribute" /> > </field> > <field name="organDonor" type="string" > > <bind-xml name="organDonor" node="attribute" /> > </field> > <field name="custSSN" type="string" > > <bind-xml name="custSSN" node="attribute" /> > </field> > <field name="gender" type="string" > > <bind-xml name="gender" node="attribute" /> > </field> > <field name="custType" type="string" > > <bind-xml name="custType" node="attribute" /> > </field> > </class> > > <!-- *********************************** Address ********************** > --> > <class name="com.trivin.bo.party.Address" > identity="castorHashCode" auto-complete="true"> > > <!-- ************* BusinessObjects Mappings > *************************************** --> > > <field name="BOFactory" get-method="getBOFactory" > type="com.trivin.bo.BOFactory" transient="true" /> > <field name="productID" type="integer" > > <bind-xml name="productID" node="attribute" /> > </field> > > <!-- ************* BusinessObjects Mappings > *************************************** --> > > <field name="addressID" type="long" transient="true" /> > > <field name="castorHashCode" type="integer" > > <bind-xml name="key" node="attribute" /> > </field> > <field name="zipCode" type="string" > > <bind-xml name="zipCode" node="attribute" /> > </field> > <field name="state" type="string" > > <bind-xml name="state" node="attribute" /> > </field> > <field name="country" type="string" > > <bind-xml name="country" node="attribute" /> > </field> > <field name="street1" type="string" > > <bind-xml name="street1" node="attribute" /> > </field> > <field name="street2" type="string" > > <bind-xml name="street2" node="attribute" /> > </field> > <field name="street3" type="string" > > <bind-xml name="street3" node="attribute" /> > </field> > <field name="city" type="string" > > <bind-xml name="city" node="attribute" /> > </field> > <field name="county" type="string" > > <bind-xml name="county" node="attribute" /> > </field> > </class> > </mapping> > > ---- Mapping file that does not work and gets the error ----- > <?xml version="1.0"?> > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version > 1.0//EN" > "http://castor.exolab.org/mapping.dtd"> > > <mapping> > <!-- *********************************** Business Object (the super > Object) ********************** --> > <class name="com.trivin.bo.BusinessObject" auto-complete="true"> > <!-- ************* Exclude > *************************************** --> > <field name="BOFactory" get-method="getBOFactory" > type="com.trivin.bo.BOFactory" transient="true" /> > <!-- > ************************************************************** --> > > <field name="productID" type="integer" > > <bind-xml name="productID" node="attribute" /> > </field> > </class> > > <!-- *********************************** Party ********************** > --> > <class name = "com.trivin.bo.party.Party" > extends="com.trivin.bo.BusinessObject" identity="castorHashCode" > auto-complete="true"> > > <!-- ************* Exclude > *************************************** --> > <field name="addressRoles" type="integer" > get-method="getAddressRoles" collection="array" transient="true" /> > <field name="partyType" type="integer" transient="true" > /> > <field name="partyID" type="long" transient="true" /> > <field name="business" type="boolean" transient="true" > /> > <field name="individual" type="boolean" > transient="true" /> > <field name="name" type="string" transient="true" /> > <!-- > ************************************************************** --> > <field name="castorHashCode" type="integer" > > <bind-xml name="key" node="attribute" /> > </field> > <field name="suspensionViolation" type="string" > > <bind-xml name="suspensionViolation" node="attribute" > /> > </field> > <field name="suspensionState" type="string" > > <bind-xml name="suspensionState" node="attribute" /> > </field> > <field name="phone" type="string" > > <bind-xml name="phone" node="attribute" /> > </field> > <field name="dmvId" type="string" > > <bind-xml name="dmvId" node="attribute" /> > </field> > <field name="FAX" type="string" > > <bind-xml name="FAX" node="attribute" /> > </field> > <field name="jurisdiction" type="string" > > <bind-xml name="Jurisdiction" node="attribute" /> > </field> > <!-- End Map of Address References --> > <field name="castorAddresses" > type="com.trivin.bo.party.Address" > collection="array" > > <bind-xml name="Address" location="Addresses"/> > </field> > <!-- Hashmap of with key as Role and Value as Address --> > <field name="addressMap" > type="org.exolab.castor.mapping.MapItem" > collection="map" > get-method="getAddressMap" > set-method="setAddressMap" > > <bind-xml> > <class name= > "org.exolab.castor.mapping.MapItem"> > <field name="key" type="integer"> > <bind-xml name="role" node = > "attribute"/> > </field> > <field name="value" > type="com.trivin.bo.party.Address"> > <bind-xml name="Address" > node="element" reference="true" /> > </field> > </class> > </bind-xml> > </field> > </class> > <!-- *********************************** Business ********************** > --> > <class name="com.trivin.bo.party.Business" > extends="com.trivin.bo.party.Party" auto-complete="true"> > <field name="name" type="string"> > <bind-xml name="Name" node="attribute"/> > </field> > <field name="doingBusinessAs" type="string" > > <bind-xml name="DBA" node="attribute" /> > </field> > <field name="feidNumber" type="string" > > <bind-xml name="FEIDNumber" node="attribute" /> > </field> > </class> > <!-- *********************************** Individual > ********************** --> > <class name="com.trivin.bo.party.Individual" > extends="com.trivin.bo.party.Party" auto-complete="true"> > <!-- ************* Exclude > *************************************** --> > <field name="eyeColor" type="string" transient="true" /> > <field name="birthDateString" type="string" > transient="true" /> > <!-- > ************************************************************** --> > > <field name="birthDate" type="date" > > <bind-xml name="birthDate" node="attribute" /> > </field> > <field name="irpExempt" type="string" > > <bind-xml name="irpExempt" node="attribute" /> > </field> > <field name="prefix" type="string" > > <bind-xml name="prefix" node="attribute" /> > </field> > <field name="firstName" type="string" > > <bind-xml name="firstName" node="attribute" /> > </field> > <field name="middleName" type="string" > > <bind-xml name="middleName" node="attribute" /> > </field> > <field name="lastName" type="string" > > <bind-xml name="lastName" node="attribute" /> > </field> > <field name="suffix" type="string" > > <bind-xml name="suffix" node="attribute" /> > </field> > <field name="organDonor" type="string" > > <bind-xml name="organDonor" node="attribute" /> > </field> > <field name="custSSN" type="string" > > <bind-xml name="custSSN" node="attribute" /> > </field> > <field name="gender" type="string" > > <bind-xml name="gender" node="attribute" /> > </field> > <field name="custType" type="string" > > <bind-xml name="custType" node="attribute" /> > </field> > </class> > > <!-- *********************************** Address ********************** > --> > <class name="com.trivin.bo.party.Address" > extends="com.trivin.bo.BusinessObject" identity="castorHashCode" > auto-complete="true"> > > > <field name="addressID" type="long" transient="true" /> > > <field name="castorHashCode" type="integer" > > <bind-xml name="key" node="attribute" /> > </field> > <field name="zipCode" type="string" > > <bind-xml name="zipCode" node="attribute" /> > </field> > <field name="state" type="string" > > <bind-xml name="state" node="attribute" /> > </field> > <field name="country" type="string" > > <bind-xml name="country" node="attribute" /> > </field> > <field name="street1" type="string" > > <bind-xml name="street1" node="attribute" /> > </field> > <field name="street2" type="string" > > <bind-xml name="street2" node="attribute" /> > </field> > <field name="street3" type="string" > > <bind-xml name="street3" node="attribute" /> > </field> > <field name="city" type="string" > > <bind-xml name="city" node="attribute" /> > </field> > <field name="county" type="string" > > <bind-xml name="county" node="attribute" /> > </field> > </class> > </mapping> > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev