Skip to content

Instantly share code, notes, and snippets.

@janernsting
Created November 28, 2012 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janernsting/4160504 to your computer and use it in GitHub Desktop.
Save janernsting/4160504 to your computer and use it in GitHub Desktop.
SE 2012 WS / Aufgabe 10
import java.util.Calendar;
import java.util.Date;
import javax.persistence.*;
@Entity
public class Bestellung {
private Long id;
private Date timestamp = Calendar.getInstance().getTime();
private Kunde besteller;
private String inhalt = "";
private String lieferhinweis = "";
protected Bestellung() { }
public Bestellung(Kunde besteller) {
this.besteller = besteller;
}
@Id @GeneratedValue
protected Long getId() { return id; }
protected void setId(Long id) { this.id = id; }
public Date getTimestamp() { return timestamp; }
protected void setTimestamp(Date t) { timestamp = t; }
@ManyToOne
public Kunde getBesteller() { return besteller; }
protected void setBesteller(Kunde besteller) { this.besteller = besteller; }
public String getInhalt() { return inhalt; }
public void setInhalt(String inhalt) { this.inhalt = inhalt; }
public String getLieferhinweis() { return lieferhinweis; }
public void setLieferhinweis(String l) { lieferhinweis = l; }
// ...
}
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.*;
@Entity
public class Kunde {
private String telefonnummer;
private String name = "";
private String adresse = "";
private String lieferhinweis = "";
private Collection<Bestellung> bestellungen = new ArrayList<Bestellung>();
protected Kunde() { }
public Kunde(String telefonnummer) {
this.telefonnummer = telefonnummer;
}
@Id
public String getTelefonnummer() { return telefonnummer; }
protected void setTelefonnummer(String t) { telefonnummer = t; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getAdresse() { return adresse; }
public void setAdresse(String adresse) { this.adresse = adresse; }
public String getLieferhinweis() { return lieferhinweis; }
public void setLieferhinweis(String l) { this.lieferhinweis = l; }
@OneToMany(mappedBy = "besteller")
public Collection<Bestellung> getBestellungen() { return bestellungen; }
protected void setBestellungen(Collection<Bestellung> b) { bestellungen = b; }
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment