cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: [jira] [Commented] (CAY-1622) Generated classes shouldn't produce serialVersionUID compiler warning
Date Mon, 03 Oct 2011 23:53:42 GMT
No, it should be more clever than that.  Otherwise, every time you
regenerate the template, the generated code will change even if
nothing else had changed.   That will also break serialization.

Ideally, it should return the same number whenever the same fields and
types are used for the generated class.

Maybe build the number by iterating over the attributes and
relationships and feeding it into
org.apache.commons.lang.builder.HashCodeBuilder, basing it on the
order and type

On Mon, Oct 3, 2011 at 7:41 PM, Ari Maniatis (Commented) (JIRA)
<> wrote:
>    [
> Ari Maniatis commented on CAY-1622:
> -----------------------------------
> Do we just want to add this to the velocity templates:
> private static final long serialVersionUID = ${random(1,9223372036854775807)};
>> Generated classes shouldn't produce serialVersionUID compiler warning
>> ---------------------------------------------------------------------
>>                 Key: CAY-1622
>>                 URL:
>>             Project: Cayenne
>>          Issue Type: Bug
>>          Components: Core Library
>>    Affects Versions: 3.0
>>            Reporter: Bob Harner
>>            Priority: Minor
>> It is probably a good idea for Cayenne not to produce any compiler warnings, but
auto-generated entity classes always have the "The serializable class _Foo does not declare
a static final serialVersionUID field of type long" compiler warning.
>> The @SuppressWarnings("serial") annotation will get rid of the warnings, but of course
it is not recommended to manually update the generated  classes.
>> Users could configure the IDE to ignore these warnings (yuk), but then other team
members will still see them.
>> Another option is to for users to set up a custom velocity template to include this
>> But the best solution would be for Cayenne to either automatically generate either
the serialVersionUID itself or the @SuppressWarnings("serial") annotation that suppresses
the compiler warning.
> --
> This message is automatically generated by JIRA.
> If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
> For more information on JIRA, see:

View raw message