Menu

Datenbank

Manuel Geier

Datenbank

Um Daten in der Datenbank abzuspeichern und zu laden wird das Datenbankframework Hibernate verwendet. Weitere Informationen zu diesem Framwork finden Sie auf http://www.hibernate.org.

Annotations

Annotation
Beschreibung

@Id
Primary Key. Wenn das Objekt noch nicht in der Datenbank ist, so ist dieser Wert null, ansonsten gibt dieser Wert die Id in der Datenbank an.

@GeneratedValue(strategy=GenerationType.AUTO)
Der Schlüssel wird automatisch von Hibernate generiert.

_@To:_
Mittels dieser Annotation können Beziehungen zwischen den Objekten festgelegt werden. Die Eigenschaft cascade (zb cascade={CascadeType.PERSIST, CascadeType.MERGE}) sollte jedoch nicht benutzt werden. Anstelle von dieser sollte die @Cascade-Annotation von Hibernate verwendet werden, da diese mehr Möglichkeiten bietet als in der Java Persistence Spezifikation.

@ManyToMany

@OneToMany(mappedBy = "PROPERTYNAME")

@ManyToOne

@Temporal:
Gibt den Zeitstempel an, welche das Datum und/oder die Uhrzeit speichert.

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
Speichert das Datum und die Uhrzeit.

@Temporal(javax.persistence.TemporalType.DATE)
Speichert nur das Datum.

@Temporal(javax.persistence.TemporalType.TIME)
Speichert nur die Uhrzeit.

@Type:

@Type(type="text")

@Cascade:
Weiterleitung. Leitet die aktuelle Aktion ([Aktionen aufzählen]) vom Objekt (this), weiter an das Objekt, an dem die Annotation steht. Hibernate bietet mehr Operationen als in der Java Persistence Spezifikation festgelegt sind.
Im Package org.hibernate.annotations.CascadeType stehen folgende Typen zur Verfügung: PERSIST, MERGE, REMOVE, REFRESH, DELETE, SAVE_UPDATE, REPLICATE, DELETE_ORPHAN, LOCK, EVICT.
Es wird empfohlen die @Cascade-Annotation von Hibernate anstelle von @To(cascade=...) zu verwenden.
Wenn mehrere Operationen verwendet werden sollen, werden diese mit einem Beistrich getrennt, zB. @Cascade({org.hibernate.annotations.!CascadeType.SAVE_UPDATE, org.hibernate.annotations.!CascadeType.DELETE_ORPHAN})

@Cascade(org.hibernate.annotations.CascadeType.NONE)
Voreinstellung; kein Kaskadieren

@Cascade(org.hibernate.annotations.CascadeType.ALL)
kaskadiert bei allen Methoden, auch denen der Hibernate-Erweiterung. Gibt aber kein delete-orphan weiter.

@Cascade(org.hibernate.annotations.CascadeType.PERSIST)
session.persist()

@Cascade(org.hibernate.annotations.CascadeType.MERGE)
session.merge()

@Cascade(org.hibernate.annotations.CascadeType.REMOVE)

@Cascade(org.hibernate.annotations.CascadeType.REFRESH)
session.refresh()

@Cascade(org.hibernate.annotations.CascadeType.DELETE)
session.delete()

@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
session.saveOrUpdate()
This is especially useful for SAVE_UPDATE (which is the operation cascaded at flush time if you use plain Hibernate Annotations - Hibernate EntityManager cascade PERSIST at flush time as per the specification).

@Cascade(org.hibernate.annotations.CascadeType.REPLICATE)
session.replicate(..)

@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
DELETE_ORPHAN applies only to @OneToMany associations, and indicates that the delete()/remove() operation should be applied to any child object that is removed from the association. In other words, if a child is dereferenced by a persistent parent and if DELETE_ORPHAN is used, the "orphaned" child is deleted.
Wenn die Beziehung gelöscht wird, werden bei einer 1:n-Beziehung die N-Objekte gelöscht, wenn für das Fremdschlüsselfeld ein Not-Null-Constraint besteht.

@Cascade(org.hibernate.annotations.CascadeType.LOCK)
session.lock()

@Cascade(org.hibernate.annotations.CascadeType.EVICT)
session.evict() löscht ein Objekt aus dem Session-Cache

`` Quellen: Galileo Annotation Referenz, JBoss Hibernate Annotations

Datenmodell

Das Datenmodell beschreibt alle Daten die in der Datenbank gespeichert werden und deren Beziehungen. Weiters werden die gesetzten Annotations für Hibernate erkärt.

Boarding School Management

Keine Daten werden in der Datenbank gespeichert.

Customer Management Module

Customer

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity

Property-Konstanten:
JA

PropertyChangeListener:
JA

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null
@Id
@GeneratedValue(strategy=GenerationType.AUTO)

active
Gibt an, ob der Kunde aktiv ist oder nicht
boolean
true

title
Titel (Prof., Dr., ...)
String
""

forename
Vorname
String
""

forename2
2. Vorname
String
""

surname
Nachname
String
""

gender
Geschlecht
boolean
true
true: männlich
false: weiblich

street
Adresse
String
""

postOfficeNumber
Postleitzahl
String
""

city
Ort
String
""

province
Bundesland
String
""

country
Staat
String
""

birthday
Geburtsdatum
Date
null
@Temporal(javax.persistence.TemporalType.TIMESTAMP)

landlinephone
Festnetztelefon
String
""

mobilephone
Mobiltelefon
String
""

fax
Fax
String
""

email
E-Mail-Adresse
String
""

creationdate
Datum der Erstellung
Date
null
@Temporal(javax.persistence.TemporalType.TIMESTAMP)

inactiveDate
Datum an dem der Kunde zuletzt inaktiv gesetzt wurde
Date
null
@Temporal(javax.persistence.TemporalType.TIMESTAMP)

comment
Kommentar
String
""
@Type(type="text")

guardian
Verweis auf den Erziehungsberechtigten
Guardian
new Guardian()
@OneToOne
@Cascade(org.hibernate.annotations.CascadeType.ALL)

groups
Liste der zugehörigen Gruppen
List<Group>
new ArrayList<Group>()
@ManyToMany

accountings
Liste der Buchungen
List<Posting>
new ArrayList<Posting>()
@OneToMany(mappedBy = "customer")

Group

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity
@Table(name="Groups"): 'Group' kann nicht als Tabellenname gewählt werden, da dies ein SQL-Command ist.

Property-Konstanten:
JA

PropertyChangeListener:
JA

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null
@Id
@GeneratedValue(strategy = GenerationType.AUTO)

name
Bezeichnung
String

deletable
Ob die Gruppe gelöscht werden kann
boolean

parent
Übergeordnete Gruppe
Group

@ManyToOne

Beliebig viele Gruppen gehören zu einer Übergruppe.

customers
Liste der Kunden in dieser Gruppe
List<Customer>
new ArrayList<Customer>()
@ManyToMany(mappedBy = "groups")

children
Liste der untergeordneten Gruppen
List<Group>
new ArrayList<Group>()
@OneToMany(mappedBy = "parent")

Eine Gruppe kann beliebig viele Untergruppen haben. Die Beziehung wird von dem Property 'parent' bestimmt.

Student Management Module

OrganisationUnit

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity

Property-Konstanten:
JA

PropertyChangeListener:
JA

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null
@Id
@GeneratedValue(strategy=GenerationType.AUTO)

name
Name
String
""

parent
Übergeordnete Organisationseinheit
OrganisationUnit
null
@ManyToOne

Eine Organisationseinheit kann nur zu einern Überorganisationseinheit gehören.

children
Liste der untergeordnete Organisationseinheiten
List<OrganisationUnit>
new ArrayList<OrganisationUnit>()
@OneToMany(mappedBy = "parent")
@OrderBy("name")

Eine Organisationseinheit kann beliebig viele Unterorganisationseinheiten haben.
Das Mapping wird vom Property parent übernommen.

studentClasses
Liste der untergeordneten Klassen
List<StudentClass>
new ArrayList<StudentClass>()
@OneToMany(mappedBy = "organisationUnit")

Das Mapping geht vom Property organisationUnit der StudentClass aus.

Student

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity

Property-Konstanten:
JA

PropertyChangeListener:
JA

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null
@Id
@GeneratedValue(strategy=GenerationType.AUTO)

studentClass
Klasse in der er sich befindet
StudentClass
null
@OneToOne

null bedeutet, er befindet sich in keiner Klasse.

customer
Verweis auf den Kunden
Customer
@OneToOne

active
Gibt an ob er aktiv ist
boolean
true

StudentClass

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity

Property-Konstanten:
JA

PropertyChangeListener:
JA

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null
@Id
@GeneratedValue(strategy=GenerationType.AUTO)

name
Name
String
""

nextStudentClass
Verweis auf die nachfolgende Klasse
StudentClass
null
@OneToOne

Dies wird benötigt, wenn die Schüler automatisch in die nächste Klasse aufsteigen sollen.

organisationUnit
Verweis auf die darinliegende Organisationseinheit
OrganisationUnit
null
@ManyToOne

Course Management Module

Activity

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity

Property-Konstanten:
JA

PropertyChangeListener:
JA

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null
@Id
@GeneratedValue(strategy=GenerationType.AUTO)

name
Name
String
""

description
Beschreibung
""
null

price
Preis
double
0.0

Course

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private String name; private Date beginDate; private Date endDate; private double price; private List<CourseAddition> courseAdditions;

CourseAddition

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

//private CourseParticipant courseParticipant; private Course course; private List<Activity> activities; private List<Subject> subjects; private double alreadyPayedAmount; private Boolean posted; private double individualPrice;

CourseParticipant

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private Customer customer; private List<CourseAddition> courseList;

CoursePosting

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private Posting posting; private CourseAddition courseAddition;

PostingRun

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private List<CoursePosting> coursePostings; private String name; private Boolean alreadyStorniert;

Subject

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private String name;

Room Management Module

Bereich

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

'

private Long id;

private String name; private Bereich parentBereich; private List<Bereich> childBereichList; private List<Zimmer> zimmerList;

Bewohner

Extends:
Model

Implements:
AnnotatedClass

Annotations:
@Entity

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

id
Eindeutige Nummer
Long
null

customer
Verweis auf den Kunden
Customer
``

zimmer
Verweis auf sein Zimmer
Zimmer
``

kaution
Kaution
``

kautionStatus
int
``

von
Date
``

bis
Date
``

active
boolean
``

BewohnerGeb

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

'

// PropertyChangeListener schreiben private Long id;

private Customer customer; private Zimmer zimmer; private Date von; private Date bis; private boolean active; private List<GebTarifSelection> gebList;

BewohnerHistory

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

'

private Long id;

private String zimmerName; private String bereichName; private Date von; private Date bis; private Date lastTimetamp; private Bewohner bewohner;

BewohnerStorno

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private Customer customer; private Zimmer zimmer; private List<Posting> postingList;

BuchungsLaufZuordnung

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private GebLauf gebLauf; private Posting posting; private Gebuehr gebuehr;

GebLauf

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private long abrMonat; private Date cpuDate; private boolean betriebsart;

Gebuehr

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private int id;

private String name; private GebuehrenKategorie gebKat; private List<Tarif> tarifList;

GebuehrZuordnung

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private Bewohner bewohner; private Gebuehr gebuehr; private Date von; private Date bis; private String anmerkung;

GebuehrenKategorie

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private String name;

GebuehrenLauf

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private int id;

private String art; private GregorianCalendar abrMonat; private int stornoLauf; private GregorianCalendar cpuDate;

Kaution

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private String name; private double betrag; protected transient PropertyChangeSupport support; public final static String PROPERTYNAME_NAME = "name"; public final static String PROPERTYNAME_BETRAG = "betrag"; public final static DecimalFormat numberFormat=new DecimalFormat("#0.00");

Tarif

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private Date ab; private Date bis; private Gebuehr gebuehr; private double tarif; private boolean active; private Date lastAccounted;

Zimmer

Extends:

Implements:

Annotations:

Property-Konstanten:

PropertyChangeListener:

``

Variable
Beschreibung
Datentyp
Standardwert
Annotation
Anmerkung

private Long id;

private String name; private Bereich bereich; private int anzbetten; private boolean activ; private List<Bewohner> bewohnerList = new ArrayList<Bewohner>();


Related

Wiki: Home