Re: serialVersionUID in autogenerated classes?

From: Jeff de Vries (jdevrie..frog.com)
Date: Mon Feb 13 2006 - 19:56:39 EST

  • Next message: Andrus Adamchik: "Fwd: Cayenne 1.2 M11 milestone"

    Thanks for the quick response and insights into the issue!

    Just to make sure I understand -

    * If I don't set any serialVersionUID (and turn off the compiler
    warning), then each time I compile a class a new,
    automatically-generated serialVersionUID is created by the compiler (or
    some part of that pipeline). This creates the potential problem that if
    something was serialized out using a previous build, and then serialized
    in using a later build, there will be an error because the UID's won't
    match. For us, this wouldn't be a problem because we bring everything
    down when we deploy a new version, so there shouldn't be any old
    serialized data laying around (and if there was, we'd get an exception,
    which is what we'd want).

    * If I do set a serialVersionUID, then the assumption is made that my
    class will be smart enough to know how to convert older versions into
    newer versions. I assume your class has to implement some method to
    handle this situation.

    If the above is correct, I think I'll be removing the serialVersionUID's
    from our code. :-)

    Thanks again,
    Jeff de Vries

    Jeff de Vries wrote:
    > We recently moved to Eclipse 3.1 from Eclipse 3.0, and now we get lots
    > of warnings along the lines of "class <foo> does not have a final,
    > static serialVersionUID". Apparently, this is something Java
    > Serializable needs. Fortunately, Eclipse has a fast way of setting
    > these (double-click on warning, then Ctrl-1 to have a serialVersionUID
    > generated and inserted for you).
    >
    > My question has to do with Cayenne's auto-generated classes. Is there
    > a way to have serialVersionUID's automatically generated and inserted
    > into the auto classes? If not, how are other people handling this issue?
    >
    > Thanks,
    > Jeff de Vries
    >



    This archive was generated by hypermail 2.0.0 : Mon Feb 13 2006 - 19:56:43 EST