streak
streak

Reputation: 1151

avoid persistance of a variable

I am trying to persist an entity class here

@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

}

The problem is teamLeader in not a field in the team table. I am just using it just to get its value from the form and using it somewhere else. how can i avoid persisting it as it is getting persisted like all other members. Please help. Thanks.

Upvotes: 1

Views: 37

Answers (1)

cyon
cyon

Reputation: 9548

You can annotate a field with the @Transient annotation to denote to the JPA implementation that it should not be persisted in the database.

@Transient
protected String teamLeader;

Upvotes: 2

Related Questions