1

我正在尝试在这里保留一个实体类

@Entity

@Table(name="team")

public class Team {

    @Id
    protected String teamId;

    protected String teamName;
    protected String teamDescription;
    protected Date createdOn;

    protected String teamLeader;

// all getter setter methodes

}

问题是 teamLeader 不是 team 表中的字段。我只是为了从表单中获取它的价值并在其他地方使用它。我怎样才能避免持久化它,因为它像所有其他成员一样持久化。请帮忙。谢谢。

4

1 回答 1

2

您可以使用注解对字段进行@Transient注解,以向 JPA 实现表明它不应保留在数据库中。

@Transient
protected String teamLeader;
于 2013-09-07T12:23:12.523 回答