Search code examples
javadictionaryxstream

Map returning reference in java


we have a map

 final Map<String, Date> releaseDate = new HashMap<String, Date>();
  ....#code to populate Map
  I have an object Movie movie =new Movie()  

when I set the value movie.setReleaseDate(releaseDate.get("test");

I add this in xml file it's showing as

<releaseDate reference="../../../movie/releaseDate"/>

it's showing the reference not the value.

when I try like

 Date date = (Date)releaseDate.get("test").clone();
  movie.setReleaseDate(date);

then in xml file showing the correct value <releaseDate>2011-07-31 23:00:00.0 UTC </releaseDate>

why map is returning the reference.How can I overcome this issue?

Thanks


Solution

  • Call xstream.setMode(XStream.NO_REFERENCES).

    See this page: http://x-stream.github.io/graphs.html

    FYI: Simple Google search for xstream reference attribute found me that link.