Java Tutorial/JPA/Transient

Материал из Java эксперт
Перейти к: навигация, поиск

Transient Field Not Persisted

File: Student.java



import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
public class Student {
  @Id
  private String id;
  transient private String name;

  
  public String getId() {
    return id;
  }
  public void setId(String id) {
    this.id = id;
  }
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }

  public String toString() {
    return "\n\nID:" + id + "\nName:" + name + "\n\n";
  }
}