Mercurial > lada > lada-server
changeset 25:34d7ecfba8d1
Added Relation to Kommentare by using the atomatic generation from database
scheme. Doesn't work as expected and so I needed to add some extra code
(eg. insertable/updateable=false)
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Fri, 26 Apr 2013 19:52:21 +0200 |
parents | dc3bfcc5f717 |
children | 47728bab8cb1 |
files | src/main/java/de/intevation/model/LKommentarP.java src/main/java/de/intevation/model/LKommentarPPK.java src/main/java/de/intevation/model/LProbe.java src/main/resources/META-INF/persistence.xml |
diffstat | 4 files changed, 423 insertions(+), 260 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/model/LKommentarP.java Fri Apr 26 19:52:21 2013 +0200 @@ -0,0 +1,76 @@ +package de.intevation.model; + +import java.io.Serializable; +import javax.persistence.*; +import java.sql.Timestamp; + + +/** + * The persistent class for the l_kommentar_p database table. + * + */ +@Entity +@Table(name="l_kommentar_p") +public class LKommentarP implements Serializable { + private static final long serialVersionUID = 1L; + private LKommentarPPK id; + private String erzeuger; + private Timestamp kDatum; + private String kText; + private LProbe LProbe; + + public LKommentarP() { + } + + + @EmbeddedId + public LKommentarPPK getId() { + return this.id; + } + + public void setId(LKommentarPPK id) { + this.id = id; + } + + + public String getErzeuger() { + return this.erzeuger; + } + + public void setErzeuger(String erzeuger) { + this.erzeuger = erzeuger; + } + + + @Column(name="k_datum") + public Timestamp getKDatum() { + return this.kDatum; + } + + public void setKDatum(Timestamp kDatum) { + this.kDatum = kDatum; + } + + + @Column(name="k_text") + public String getKText() { + return this.kText; + } + + public void setKText(String kText) { + this.kText = kText; + } + + + //bi-directional many-to-one association to LProbe + @ManyToOne + @JoinColumn(name="probe_id", insertable=false, updatable=false) + public LProbe getLProbe() { + return this.LProbe; + } + + public void setLProbe(LProbe LProbe) { + this.LProbe = LProbe; + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/model/LKommentarPPK.java Fri Apr 26 19:52:21 2013 +0200 @@ -0,0 +1,57 @@ +package de.intevation.model; + +import java.io.Serializable; +import javax.persistence.*; + +/** + * The primary key class for the l_kommentar_p database table. + * + */ +@Embeddable +public class LKommentarPPK implements Serializable { + //default serial version id, required for serializable classes. + private static final long serialVersionUID = 1L; + private String probeId; + private Integer kId; + + public LKommentarPPK() { + } + + @Column(name="probe_id") + public String getProbeId() { + return this.probeId; + } + public void setProbeId(String probeId) { + this.probeId = probeId; + } + + @Column(name="k_id") + public Integer getKId() { + return this.kId; + } + public void setKId(Integer kId) { + this.kId = kId; + } + + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof LKommentarPPK)) { + return false; + } + LKommentarPPK castOther = (LKommentarPPK)other; + return + this.probeId.equals(castOther.probeId) + && this.kId.equals(castOther.kId); + } + + public int hashCode() { + final int prime = 31; + int hash = 17; + hash = hash * prime + this.probeId.hashCode(); + hash = hash * prime + this.kId.hashCode(); + + return hash; + } +} \ No newline at end of file
--- a/src/main/java/de/intevation/model/LProbe.java Fri Apr 26 18:06:21 2013 +0200 +++ b/src/main/java/de/intevation/model/LProbe.java Fri Apr 26 19:52:21 2013 +0200 @@ -1,260 +1,287 @@ -package de.intevation.model; - -import java.io.Serializable; -import javax.persistence.*; +package de.intevation.model; + +import java.io.Serializable; +import javax.persistence.*; import java.sql.Timestamp; - - -/** - * The persistent class for the l_probe database table. - * - */ -@Entity -@Table(name="l_probe") -public class LProbe implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="probe_id") - private String probeId; - - @Column(name="ba_id") - private String baId; - - @Column(name="datenbasis_id") - private Integer datenbasisId; - - @Column(name="erzeuger_id") - private Integer erzeugerId; - - @Column(name="hauptproben_nr") - private String hauptprobenNr; - - @Column(name="letzte_aenderung") - private Timestamp letzteAenderung; - - private String media; - - @Column(name="media_desk") - private String mediaDesk; - - private Long mittelungsdauer; - - @Column(name="mp_kat") - private String mpKat; - - @Column(name="mpl_id") - private String mplId; - - @Column(name="mpr_id") - private Integer mprId; - - @Column(name="mst_id") - private String mstId; - - @Column(name="netzbetreiber_id") - private String netzbetreiberId; - - @Column(name="probe_nehmer_id") - private Integer probeNehmerId; - - @Column(name="probeentnahme_beginn") - private Timestamp probeentnahmeBeginn; - - @Column(name="probeentnahme_ende") - private Timestamp probeentnahmeEnde; - - @Column(name="probenart_id") - private Integer probenartId; - - @Column(name="solldatum_beginn") - private Timestamp solldatumBeginn; - - @Column(name="solldatum_ende") - private Timestamp solldatumEnde; - - private Boolean test; - - @Column(name="umw_id") - private String umwId; - - public LProbe() { - } - - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - public String getBaId() { - return this.baId; - } - - public void setBaId(String baId) { - this.baId = baId; - } - - public Integer getDatenbasisId() { - return this.datenbasisId; - } - - public void setDatenbasisId(Integer datenbasisId) { - this.datenbasisId = datenbasisId; - } - - public Integer getErzeugerId() { - return this.erzeugerId; - } - - public void setErzeugerId(Integer erzeugerId) { - this.erzeugerId = erzeugerId; - } - - public String getHauptprobenNr() { - return this.hauptprobenNr; - } - - public void setHauptprobenNr(String hauptprobenNr) { - this.hauptprobenNr = hauptprobenNr; - } - - public Timestamp getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Timestamp letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - public String getMedia() { - return this.media; - } - - public void setMedia(String media) { - this.media = media; - } - - public String getMediaDesk() { - return this.mediaDesk; - } - - public void setMediaDesk(String mediaDesk) { - this.mediaDesk = mediaDesk; - } - - public Long getMittelungsdauer() { - return this.mittelungsdauer; - } - - public void setMittelungsdauer(Long mittelungsdauer) { - this.mittelungsdauer = mittelungsdauer; - } - - public String getMpKat() { - return this.mpKat; - } - - public void setMpKat(String mpKat) { - this.mpKat = mpKat; - } - - public String getMplId() { - return this.mplId; - } - - public void setMplId(String mplId) { - this.mplId = mplId; - } - - public Integer getMprId() { - return this.mprId; - } - - public void setMprId(Integer mprId) { - this.mprId = mprId; - } - - public String getMstId() { - return this.mstId; - } - - public void setMstId(String mstId) { - this.mstId = mstId; - } - - public String getNetzbetreiberId() { - return this.netzbetreiberId; - } - - public void setNetzbetreiberId(String netzbetreiberId) { - this.netzbetreiberId = netzbetreiberId; - } - - public Integer getProbeNehmerId() { - return this.probeNehmerId; - } - - public void setProbeNehmerId(Integer probeNehmerId) { - this.probeNehmerId = probeNehmerId; - } - - public Timestamp getProbeentnahmeBeginn() { - return this.probeentnahmeBeginn; - } - - public void setProbeentnahmeBeginn(Timestamp probeentnahmeBeginn) { - this.probeentnahmeBeginn = probeentnahmeBeginn; - } - - public Timestamp getProbeentnahmeEnde() { - return this.probeentnahmeEnde; - } - - public void setProbeentnahmeEnde(Timestamp probeentnahmeEnde) { - this.probeentnahmeEnde = probeentnahmeEnde; - } - - public Integer getProbenartId() { - return this.probenartId; - } - - public void setProbenartId(Integer probenartId) { - this.probenartId = probenartId; - } - - public Timestamp getSolldatumBeginn() { - return this.solldatumBeginn; - } - - public void setSolldatumBeginn(Timestamp solldatumBeginn) { - this.solldatumBeginn = solldatumBeginn; - } - - public Timestamp getSolldatumEnde() { - return this.solldatumEnde; - } - - public void setSolldatumEnde(Timestamp solldatumEnde) { - this.solldatumEnde = solldatumEnde; - } - - public Boolean getTest() { - return this.test; - } - - public void setTest(Boolean test) { - this.test = test; - } - - public String getUmwId() { - return this.umwId; - } - - public void setUmwId(String umwId) { - this.umwId = umwId; - } - -} +import java.util.List; + + +/** + * The persistent class for the l_probe database table. + * + */ +@Entity +@Table(name="l_probe") +public class LProbe implements Serializable { + private static final long serialVersionUID = 1L; + private String probeId; + private String baId; + private Integer datenbasisId; + private Integer erzeugerId; + private String hauptprobenNr; + private Timestamp letzteAenderung; + private String media; + private String mediaDesk; + private Long mittelungsdauer; + private String mpKat; + private String mplId; + private Integer mprId; + private String mstId; + private String netzbetreiberId; + private Integer probeNehmerId; + private Timestamp probeentnahmeBeginn; + private Timestamp probeentnahmeEnde; + private Integer probenartId; + private Timestamp solldatumBeginn; + private Timestamp solldatumEnde; + private Boolean test; + private String umwId; + private List<LKommentarP> LKommentarPs; + + public LProbe() { + } + + + @Id + @Column(name="probe_id") + public String getProbeId() { + return this.probeId; + } + + public void setProbeId(String probeId) { + this.probeId = probeId; + } + + + @Column(name="ba_id") + public String getBaId() { + return this.baId; + } + + public void setBaId(String baId) { + this.baId = baId; + } + + + @Column(name="datenbasis_id") + public Integer getDatenbasisId() { + return this.datenbasisId; + } + + public void setDatenbasisId(Integer datenbasisId) { + this.datenbasisId = datenbasisId; + } + + + @Column(name="erzeuger_id") + public Integer getErzeugerId() { + return this.erzeugerId; + } + + public void setErzeugerId(Integer erzeugerId) { + this.erzeugerId = erzeugerId; + } + + + @Column(name="hauptproben_nr") + public String getHauptprobenNr() { + return this.hauptprobenNr; + } + + public void setHauptprobenNr(String hauptprobenNr) { + this.hauptprobenNr = hauptprobenNr; + } + + + @Column(name="letzte_aenderung") + public Timestamp getLetzteAenderung() { + return this.letzteAenderung; + } + + public void setLetzteAenderung(Timestamp letzteAenderung) { + this.letzteAenderung = letzteAenderung; + } + + + public String getMedia() { + return this.media; + } + + public void setMedia(String media) { + this.media = media; + } + + + @Column(name="media_desk") + public String getMediaDesk() { + return this.mediaDesk; + } + + public void setMediaDesk(String mediaDesk) { + this.mediaDesk = mediaDesk; + } + + + public Long getMittelungsdauer() { + return this.mittelungsdauer; + } + + public void setMittelungsdauer(Long mittelungsdauer) { + this.mittelungsdauer = mittelungsdauer; + } + + + @Column(name="mp_kat") + public String getMpKat() { + return this.mpKat; + } + + public void setMpKat(String mpKat) { + this.mpKat = mpKat; + } + + + @Column(name="mpl_id") + public String getMplId() { + return this.mplId; + } + + public void setMplId(String mplId) { + this.mplId = mplId; + } + + + @Column(name="mpr_id") + public Integer getMprId() { + return this.mprId; + } + + public void setMprId(Integer mprId) { + this.mprId = mprId; + } + + + @Column(name="mst_id") + public String getMstId() { + return this.mstId; + } + + public void setMstId(String mstId) { + this.mstId = mstId; + } + + + @Column(name="netzbetreiber_id") + public String getNetzbetreiberId() { + return this.netzbetreiberId; + } + + public void setNetzbetreiberId(String netzbetreiberId) { + this.netzbetreiberId = netzbetreiberId; + } + + + @Column(name="probe_nehmer_id") + public Integer getProbeNehmerId() { + return this.probeNehmerId; + } + + public void setProbeNehmerId(Integer probeNehmerId) { + this.probeNehmerId = probeNehmerId; + } + + + @Column(name="probeentnahme_beginn") + public Timestamp getProbeentnahmeBeginn() { + return this.probeentnahmeBeginn; + } + + public void setProbeentnahmeBeginn(Timestamp probeentnahmeBeginn) { + this.probeentnahmeBeginn = probeentnahmeBeginn; + } + + + @Column(name="probeentnahme_ende") + public Timestamp getProbeentnahmeEnde() { + return this.probeentnahmeEnde; + } + + public void setProbeentnahmeEnde(Timestamp probeentnahmeEnde) { + this.probeentnahmeEnde = probeentnahmeEnde; + } + + + @Column(name="probenart_id") + public Integer getProbenartId() { + return this.probenartId; + } + + public void setProbenartId(Integer probenartId) { + this.probenartId = probenartId; + } + + + @Column(name="solldatum_beginn") + public Timestamp getSolldatumBeginn() { + return this.solldatumBeginn; + } + + public void setSolldatumBeginn(Timestamp solldatumBeginn) { + this.solldatumBeginn = solldatumBeginn; + } + + + @Column(name="solldatum_ende") + public Timestamp getSolldatumEnde() { + return this.solldatumEnde; + } + + public void setSolldatumEnde(Timestamp solldatumEnde) { + this.solldatumEnde = solldatumEnde; + } + + + public Boolean getTest() { + return this.test; + } + + public void setTest(Boolean test) { + this.test = test; + } + + + @Column(name="umw_id") + public String getUmwId() { + return this.umwId; + } + + public void setUmwId(String umwId) { + this.umwId = umwId; + } + + + //bi-directional many-to-one association to LKommentarP + @OneToMany(mappedBy="LProbe", cascade={CascadeType.ALL}, fetch=FetchType.EAGER) + public List<LKommentarP> getLKommentarPs() { + return this.LKommentarPs; + } + + public void setLKommentarPs(List<LKommentarP> LKommentarPs) { + this.LKommentarPs = LKommentarPs; + } + + public LKommentarP addLKommentarP(LKommentarP LKommentarP) { + getLKommentarPs().add(LKommentarP); + LKommentarP.setLProbe(this); + + return LKommentarP; + } + + public LKommentarP removeLKommentarP(LKommentarP LKommentarP) { + getLKommentarPs().remove(LKommentarP); + LKommentarP.setLProbe(null); + + return LKommentarP; + } + +} \ No newline at end of file
--- a/src/main/resources/META-INF/persistence.xml Fri Apr 26 18:06:21 2013 +0200 +++ b/src/main/resources/META-INF/persistence.xml Fri Apr 26 19:52:21 2013 +0200 @@ -6,9 +6,12 @@ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="primary"> <jta-data-source>java:/jboss/postgresql</jta-data-source> + <class>de.intevation.model.LKommentarP</class> + <class>de.intevation.model.LKommentarPPK</class> + <class>de.intevation.model.LProbe</class> + <class>de.intevation.model.PProbe</class> <!-- If you are running in a production environment, add a managed data source, the example data source is just for development and testing! --> - <class>de.intevation.model.LProbe</class> <properties> <!-- Properties for Hibernate --> <property name="hibernate.show_sql" value="true" />