Re: serialization issue

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu May 18 2006 - 10:17:30 EDT

  • Next message: Tomi NA: "Re: serialization issue"

    On May 18, 2006, at 6:54 AM, Tomi NA wrote:

    > I have a couple of questions about this.
    > First, is there any special reason the templates, the DataObject and
    > the ObjectId class don't have a serialVersionUID?

    We should probably add serialVersionUID to all serializable classes
    (and somehow add it to cgen templates) - this may be an improvement
    to the future versions. But the JVM should not throw an exception
    when it is absent either. So are you getting some kind of warning, or
    is this an exception?

    > Second, is it possible at all to successfuly serialize a class
    > representing a database entity?

    Absolutely. Serialization of DataObjects worked since Cayenne 1.0.
    The easiest way is to serialize the entire DataContext; if you
    serialize individual objects, you will have to manually reattach them
    to the context on deserialization (e.g. by calling 'localObject').

    > Won't the serialization algorithm get
    > just about the entire database, following the bean getters?

    No, Java serialization does not use getters, it serializes fields
    directly. However IIRC Java bean serialization does - so this can be
    a problem.

    > I'd very much appreciate a comment on the topic, as well as a prod in
    > the right direction concerning cayenne DataObject serialization.
    > Should I be looking at decode/encodeXML?

    If you don't care about the format, Java binary serialization should
    be more efficient than XML.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu May 18 2006 - 10:17:55 EDT