Hello, 
  
I'm trying to marshal/unmarshal my Java model which is a bit complex : 
* I've got many concrete classes A1,A2,..,An which extend an abstract class
A.
* I've got a class B that contains a HashSet of class A (so this set can
contain A1, A3, A5, and so on)

The problem is that when Castor marshalls my model with the specified
mapping file, it first marshalls A1 and A2 (for example) as I told him, but
it re-marshalls them if they are in the HashSet. Since class A is very big,
I'd like to put in my HashSet only references to my classes, but I don't
know how to do so... i'm new to Castor and XML... I tried using "id",
"reference", and "location" in my mapping file, but I didn't manage to do
somethin workin

Here is an extract of my mapping file:

  <class name="A1" extends="A">
    ...
  </class>
  
        <class name="B">
                <field name="a" type="A" collection="set">
                        <bind-xml name="a" node="element"/>
                </field>
        </class>

And here is the associated Java code :

abstract class A
{
  ....
}

class A1 extends A
{
  ....
}

class A2 extends A
{
  ....
}

class B
{
  // Set containing some A1, A2, and other "A-class"
  HashSet mySet;
  
  myMethod()
  {
    mySet.add( new A1() );
    mySet.add( new A2() );
  }
}


  Many thanks for your help.
  
  Regards, 
  
  xavier tello.
---------------------------------------------------------

CE COURRIER ELECTRONIQUE EST A USAGE STRICTEMENT INFORMATIF ET NE SAURAIT ENGAGER DE 
QUELQUE MANIERE QUE CE SOIT ASTRIUM SAS, NI SES FILIALES.

SI UNE ERREUR DE TRANSMISSION OU UNE ADRESSE ERRONEE A MAL DIRIGE CE COURRIER, MERCI 
D'EN INFORMER L'EXPEDITEUR EN LUI FAISANT UNE REPONSE PAR COURRIER ELECTRONIQUE DES 
RECEPTION. SI VOUS N'ETES PAS LE DESTINATAIRE DE CE COURRIER, VOUS NE DEVEZ PAS 
L'UTILISER, LE CONSERVER, EN FAIRE ETAT, LE DISTRIBUER, LE COPIER, L'IMPRIMER OU EN 
REVELER LE CONTENU A UNE TIERCE PARTIE.



This email is for information only and will not bind Astrium SAS in any contract or 
obligation, nor its subsidiaries.

If you have received it in error, please notify the sender by return email. If you are 
not the addressee of this email, you must not use, keep, disseminate, copy, print or 
otherwise deal with it.

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

Reply via email to