Hi Damian,

I tried to look into this, but the classes in your zip file won't
compile as the zip is missing some required files.

--Keith

[EMAIL PROTECTED] wrote:



Keith,

The castor properties file, the mapping.xml and the test case class are
included in the attached zip file.
Most of the classes are irrelevant base classes and interfaces but the
tests obviously won't run/compile if they are not included.

The test case in question is testMarshall - this will generate a stack
overflow.

Thanks,
Damian

(See attached file: xmlbinder.zip)










Damian,

Can you send me a simple test case which I can run locally here to see
the problem.

Thanks,

--Keith

[EMAIL PROTECTED] wrote:



I have double-checked and can confirm I am using the only non-static
marshall
method: marshaller.marshal(instance);

I can also confirm the mapping file is being loaded and used, as when I
remove
the declarationItem reference from the underlying bean class, the objects
are
marshalled according to the mapping file definitions - the fields marked
transient do not appear in the marshalled xml.

Similarly the multi-word field names (ie: declarationText) are marshalled
according to the default naming convention (ie: to declaration-text).

Could this problem be related to any particular properties file setting?
Is there anything else you need to configure to get references working?

Of note, the stack overflow excpetion appears to revolve around hashCode
generation methods.   I have included a copy the Declaration class source
below
for reference to this (80 character limit prevents both from being

posted).

Likewise the DeclarationItem
hashcode method references the Declaration class in the same way....


Thanks,
Damian


public class Declaration extends BaseObject {

private static final long serialVersionUID = -1799087741240722274L;
private boolean mandatory;
private DeclarationItem declarationItem;

/**
 * @hibernate.property mandatory
 */
public boolean isMandatory() {
     return mandatory;
}

   public void setMandatory(boolean mandatory) {
       this.mandatory = mandatory;
   }

   public DeclarationItem getDeclarationItem() {
                         return declarationItem;
   }

   public void setDeclarationItem(DeclarationItem declarationItem) {
       this.declarationItem = declarationItem;
   }

   public boolean equals(Object object) {
       if (!(object instanceof Declaration)) {
           return false;
       }
       Declaration rhs = (Declaration) object;
       return new
EqualsBuilder().appendSuper(super.equals(object)).append(
               this.declarationItem, rhs.declarationItem).append(
               this.mandatory, rhs.mandatory).isEquals();
   }

   public int hashCode() {
       return new HashCodeBuilder(-1890238713, -66996781).appendSuper(
               super.hashCode()).append(this.declarationItem).append(
               this.mandatory).toHashCode();
   }

   public String toString() {
       return new ToStringBuilder(this).append("id",

this.getId()).append(

               "declarationItem",
this.declarationItem).append("mandatory",
               this.mandatory).toString();
   }
}





Damian,

Are you certain that Castor is using your mapping file? Your xml names
are the same as the default introspection names so it may be that Castor
isn't actually using your mapping file. Make sure you are not using one
of the static marshal methods.

--Keith

[EMAIL PROTECTED] wrote:



Hi,

I am using castor 0.9.9 (previously 0.9.7 to no avail either) for runtime
mapping-file based xml binding, to and from a set of existing domain
objects.  I have encountered a problem with circular dependency whereby
stack
overflow occurrs as a result of infiinte looping between the objects.

The solution to this is fairly well documented in that one side of the
relationship refere to the other as a reference via mapping file
definintion.  This sounds (and should be) relatively easy, however castor
seems
to be ignoring my mapping file definition in this (and only this)

respect.


From the mapping file below you can see I am sinply trying to have
Declaration reference its
declarationItem attribute as a reference; however this still generates
stack overflow.

If anyone can help with this (what should be) simple problem it would be
most appreciated.

Thanks
Damian Phillips


<?xml version="1.0" encoding="UTF-8"?>
<mapping xmlns="http://castor.exolab.org/";
xmlns:cst="http://castor.exolab.org/";>

<description>Castor generated mapping file</description>
    <class cst:name="package.Declaration" auto-complete="false">
          <description>Default mapping for class
package.Declaration</description>
          <map-to cst:xml="declaration"/>
          <field cst:name="mandatory" cst:type="boolean">
                <bind-xml name="mandatory" node="element" /></field>
          <field cst:name="deleted" cst:type="boolean">
                <bind-xml name="deleted" node="element"
transient="true"/></field>
          <field cst:name="versionId" cst:type="long">
                <bind-xml name="version-id" node="element"/></field>
          <field cst:name="dirty" cst:type="boolean">
                <bind-xml name="dirty" node="element"
transient="true"/></field>
          <field cst:name="created" cst:type="boolean">
                <bind-xml name="created" node="element"
transient="true"/></field>
          <field cst:name="id" cst:type="java.lang.Long">
                <bind-xml name="id" node="element"/></field>
          <field cst:name="declarationItem"
cst:type="package.DeclarationItem">
                <bind-xml name="declaration-item" reference="true"
node="attribute"/></field>
    </class>

    <class cst:name="package.DeclarationItem" auto-complete="false"
identity="id">
          <description>Default mapping for
package.DeclarationItem</description>
          <map-to cst:xml="declaration-item"/>
          <field cst:name="id" cst:type="java.lang.Long">
                <bind-xml node="attribute"/></field>
          <field cst:name="deleted" cst:type="boolean">
                <bind-xml name="deleted" node="element"
transient="true"/></field>
          <field cst:name="versionId" cst:type="long">
                <bind-xml name="version-id" node="element"/></field>
          <field cst:name="dirty" cst:type="boolean">
                <bind-xml name="dirty" node="element"
transient="true"/></field>
          <field cst:name="created" cst:type="boolean">
                <bind-xml name="created" node="element"
transient="true"/></field>
          <field cst:name="declarationText"

cst:type="java.lang.String">

                <bind-xml name="declaration-text"
node="element"/></field>
          <field cst:name="declarations" cst:type="package.Declaration"
collection="collection">
                <bind-xml name="declarations" node="element"/>
          </field>
    </class>
</mapping>


-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------





-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------





-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------





-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




------------------------------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------



-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to