Hi Alexander,
Alexander Buchholtz wrote:
> Hi,
>
> I'm facing an issue with serializing our entities to XML. We have a
> generic that is used for localization of our entities.
>
> My data model looks as follows:
>
> @MappedSuperclass
> public class LocalizationName<LocalizationNameObject> extends
> private int id;
> protected LocalizationNameObject localizationObject;
> protected String locale;
> protected String localizedName;
> }
>
> @MappedSuperclass
> public abstract class LocalizableName<LocalizableClass extends
> LocalizationName> {
> @OneToMany(cascade = CascadeType.ALL, mappedBy =
> "localizationObject")
> protected List<LocatableClass> localizationNames = new
> ArrayList<LocatableClass>();
> }
>
> @Entity
> public class WorkflowRole extends
> LocalizableName<WorkflowRoleNameLocalization>{ }
>
> @Entity
> public class WorkflowRoleNameLocalization extends
> LocalizationName<WorkflowRole> {
> }
>
> If I serialize a WorkflowRole and try to
> 1. set an alias for and
> 2. omit the "id" field of LocalizationName
> by setting:
>
> xstream.omitField(WorkflowRoleNameLocalization.class, "id");
> // doesn't work either
This is what normally works:
> xstream.omitField(LocalizationName.class, "id");
The same for the alias:
> xstream.alias("wfRoleLoc", WorkflowRoleNameLocalization.class);
>
> these are ignored. I get the following XML:
>
> <workflowRole>
> <localizationNames>
> <com.acme.workflow.WorkflowRoleNameLocalization>
> <id>27</id>
> <localizationObject class="com.acme.workflow.WorkflowRole"
> reference="../../.."/>
> <locale>de</locale>
> <localizedName>Role 1</localizedName>
> </com.acme.workflow.WorkflowRoleNameLocalization>
> </localizationNames>
> </workflowRole>
>
> Do you have any suggestions how I can work around this or what I'm doing
> wrong? I need to remove at least the ID's as I want to re-persist them in
> a different database.
Actually I have no experience with the Hibernate stuff at all, therefore I
don't know, if it really can make a difference. However, I'd be wondering.
Can you create a version of the classes above without the Hibernate stuff,
create an instance and marshal that to XML?
How do you initialize the XStream instance?
- Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email