不要在SQL语句中包含Bean变量

时间:2015-04-19 18:19:17

标签: java hibernate playframework entity ebean

我有一个Ebeans Entity类,如下所示:

@Entity
public class User {

    @Id
    private Long userid;
    @Constraints.Required
    private String username;
    private boolean active;
    private String img;
    private String status;
    private int value;
    private int gender; // 0 = female, 1 = male
    private int orientation; // 0 = straight, 1 = gay, 2 = bi

    private int listIndex; // used to store listindex for page references
    private int precessor; // used to link the pages
    private int sucessor;

    private static final int USER_AMOUNT = 50;

    /* FINDER */
    public static Model.Finder<Long,User> find = new Model.Finder<Long, User>(
            Long.class, User.class
    );

对象中需要listIndex precessorsucessor个变量,但数据库中不存在这些变量。 Finder相信它们是,这使我的SQL语句失败。

所以我的问题是,我可以告诉Finder不要在SQL语句中包含这三个变量吗?

1 个答案:

答案 0 :(得分:2)

在您不想保留的字段上使用@Transient注释,例如

@Transient
private int listIndex;