0

I am writing an Play Framework Entity which extends from play.db.ebean.Model and get this warning from eclipse:

The serializable class user does not declare a static final serialVersionUID field of type long

Can anyone explain this to me? play.db.ebean.Model ( http://www.playframework.com/documentation/2.0.3/api/java/play/db/ebean/Model.html ) doesnt not implement serializable, neither does my User class, ergo I do not understand why eclipse throws the warning.

Here is the important part of my code:

package models;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import javax.persistence.Entity;
import javax.persistence.Id;

import crypto.PasswordHash;
import play.Logger;
import play.db.ebean.Model;
import play.data.validation.*;

@Entity
public class User extends Model {

    @Id
    @Constraints.Email
    private String email;
    @Constraints.Required
    private String name;
    @Constraints.Required
    @Constraints.MinLength(5)
    private String password;
    @Constraints.Min(0)
    private Integer rating;

    ...

}
Jakob Abfalter
  • 4,980
  • 17
  • 54
  • 94
  • A guess would be that this requirement comes in through `@Entity` (as a Java EE 5 entity must be serializable). – Thorbjørn Ravn Andersen Apr 13 '14 at 19:29
  • possible duplicate of [What does it mean: The serializable class does not declare a static final serialVersionUID field?](http://stackoverflow.com/questions/2288937/what-does-it-mean-the-serializable-class-does-not-declare-a-static-final-serial) – Azar Apr 13 '14 at 19:44
  • Not really a duplicate, I am not trying to understand why I should add the variable, but rather why I should implement serializable, or why I should add the variable, when I do not implement the interface. – Jakob Abfalter Apr 13 '14 at 20:14

1 Answers1

1

Although it doesn't say so in the javadoc you linked, play.db.ebean.Model implements com.avaje.ebean.bean.EntityBean (see https://github.com/playframework/play-ebean/blob/master/play-ebean/src/main/java/play/db/ebean/Model.java), which in turn extends java.io.Serializable (see http://www.avaje.org/static/javadoc/pub/com/avaje/ebean/bean/EntityBean.html). So, Eclipse is correct.

Stefan Frye
  • 2,007
  • 1
  • 20
  • 24