Convert your PersistentBag to an ArrayList before giving it to the client.
Ian
I'm not 100% clear what you mean, but I think you're saying that you
have a problem when you have a cyclic object graph and part of that
graph is one or more persistent collections.
You're certainly right that you can't use a tree-based algorithm on a
graph because graphs aren't trees--as soon as you add a cycle, you get
stack overflow problems, not to mention duplicate copies of things.
But you can use a graph-based algorithm on an object graph and come
out with a consistent deep copy that uses standard java.util
collections in place of Hibernate's persistent versions.
I have written my own, purpose-built tool that does the above, but
there are general tools available for download. I think Dozer does
what you want, but I've never used it myself, and you might want to
look at Hibernate4GWT. If you want to roll your own, the basic
algorithm is as follows:
- start at some "root" of the graph--a top-level bean, or a collection thereof
- create an instance that represents a shallow copy of the root of the graph
- create an IdentityHashMap from input object to output object and use
it to map the root to its shallow copy
- iteratively, walk across the object graph and "deepen" the shallow
copy of the root as you go but, each time you encounter an object to
be copied, check your IdentityHashMap to see if you've copied this
object before--if you have, use the old copy, if you haven't, create a
new copy and add it to the map
Once you've finished visiting all nodes in the graph, you'll have a
deep copy of the root object without stack overflow and, assuming the
original object graph consumes O(N) memory, then, at the peak, you'll
be using about O(3N) during the copy, so it should fit into RAM, too.
Ian
java.sql.Date and the related types in java.sql will be supported by GWT 1.5.
Ian
I thought they were already supported, but I haven't used them myself.
The commit that permitted their use went in at the end of May (it was
around the time of the Goole I/O conference in San Francisco).
Perhaps you've found a bug?
Ian