I have, now that you mentioned it :)
So I made a mapping file and added two uniqueId fields to my objects. Still
no luck.
Here is my mapping file
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.org/mapping.dtd">
<mapping>
<class name="test.dima.Book" identity="bookUniqueId">
<field name="bookUniqueId" type="string">
<bind-xml name="bookUniqueId" node="attribute" />
</field>
<field name="backpointer" type="test.dima.Library" >
<bind-xml name="backpointer" reference ="true" />
</field>
</class>
<class name="test.dima.Library" identity="libraryUniqueId">
<field name="libraryUniqueId" type="string">
<bind-xml name="libraryUniqueId" node="attribute" />
</field>
<field name="books" type="test.dima.Book" collection="collection" >
<bind-xml name="book" />
</field>
</class>
</mapping>
And here is my XML output. Note it doesn't contain backreference to the
library
<?xml version="1.0" encoding="UTF-8"?>
<library libraryUniqueId="library_id_1">
<book bookUniqueId="book_id_1" />
<book bookUniqueId="book_id_2" />
</library>
Dima
On Feb 19, 2008 4:58 PM, Werner Guttmann <[EMAIL PROTECTED]> wrote:
> Can I assume that you have come across ...
>
> http://castor.org/how-to-use-references-in-xml.html
>
> Regards
> Werner
>
> Dmytro wrote:
> > I wonder if there is a way to have Castor properly handle
> backreferences.
> >
> > For example: I have a Library that contains a list of Books but each
> > book also has a backreference to a Library it is contained at.
> > The problem I have is when it is persisted into XML the backreference is
> > not there.
> >
> > Here are my 2 classes
> >
> > public class Library
> > {
> > List books = null;
> >
> > public List getBooks()
> > {
> > return this.books;
> > }
> >
> > public void setBooks(List books)
> > {
> > this.books = books;
> > }
> >
> > public Library()
> > {
> > super();
> > }
> >
> > }
> >
> > public class Book
> > {
> > private String title;
> > private String author;
> > private String price;
> > private Library backpointer;
> >
> > public void setBackpointer(Library backpointer)
> > {
> > this.backpointer = backpointer;
> > }
> >
> > public Library getBackpointer()
> > {
> > return this.backpointer;
> > }
> >
> > public Book()
> > {
> > super();
> > }
> >
> > public String getAuthor()
> > {
> > return this.author;
> > }
> >
> > public void setAuthor(String author)
> > {
> > this.author = author;
> > }
> >
> > ......................the rest of getters and setters
> > }
> >
> >
> >
> > The XML generated is
> >
> > <library>
> > <books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:type="java:test.dima.Book">
> > <author>aaa</author>
> > <price>3</price>
> > <title>rrr</title>
> > </books>
> > <books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:type="java:test.dima.Book">
> > <author>aaa2</author>
> > <price>32</price>
> > <title>rrr2</title>
> > </books>
> > </library>
> >
> >
> >
> > As you can see under <book> node there is no backreference to Library.
> > Is there special way I can configure mapping to accomplish this?
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>