cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: Cayenne-generated classes need @SuppressWarnings("serial")
Date Tue, 04 Oct 2011 14:32:52 GMT
I wrote the wrong thing in my message.  It should have been "generated
superclass" rather than "generated subclass" -- hopefully it was still
obvious we're talking about the generated class from the context.

While it's true that SerialVersionUID is not useful for the subclass's
serialization, as far as I can tell, it is still necessary for the
generated superclass class itself.   The serialization process seems
to serialize the superclass state based on their own SerialVersionUIDs
-- that seems like the logical way to do it in any case as otherwise a
subclass would have to know the implementation details for all
superclasses.  And in our specific case, where in the common case all
of the state is in the generated class, it's the only place it really
matters.

Please correct me if I'm wrong.

And I see now that the JIRA contains a working fix based on the
ObjModel, which I think is a better solution than using the default
serial generation.

On Tue, Oct 4, 2011 at 10:25 AM, Durchholz, Joachim
<Joachim.Durchholz@hennig-fahrzeugteile.de> wrote:
>> -- SerialVersionUID seems to matter on the generated subclass,
>> especially since this is where all of the state of CayenneDataObject
>> exists.  But I can only infer this -- I cannot find a specific
>> statement.  [1] [2]
>
> I can ;-)
>
>> [1] http://download.oracle.com/javase/1,5.0/docs/api/java/io/Serializable.html
>
> Last sentence on the page:
>
> "It is also strongly advised that explicit serialVersionUID declarations use the private
modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID
fields are not useful as inherited members."
>
> Actually, I slightly disagree with that sentence: a class could build its SerialVersionUID
working off the superclass' SerialVersionUID.
> But the serialization mechanism itself does not use superclass SerialVersionUIDs AFAIK.
>
> Regards,
> Jo
>

Mime
View raw message