/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa20beispiel1;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author x
 */
@Entity
public class Mitarbeiter implements Serializable {

  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private int id;
  //@Column(length = 2) //maximal zwei Zeichen
  private String name;

  public Mitarbeiter() {
  } //parameterloser Konstruktor benötigt

  public Mitarbeiter(String name) {
    this.name = name;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (id != 0 ? id : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Mitarbeiter)) {
      return false;
    }
    Mitarbeiter other = (Mitarbeiter) object;
    return id==other.id;
  }

  @Override
  public String toString() {
    return name + "(" + id + ")";
  }
}
