<name>Andreas Kuhtz</name>
<email>andreas.kuhtz@gmail.com</email>
</contributor>
+ <contributor>
+ <name>Heer Fabio</name>
+ <email>fabio.heer@dvbern.ch</email>
+ </contributor>
<!--
<contributor>
<name></name>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <groupId>ch.dvbern.demo</groupId>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>server</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <configuration>
+ <ejbVersion>3.2</ejbVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>ch.dvbern.demo</groupId>
+ <artifactId>shared</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${version.hibernate}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.2_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.annotation</groupId>
+ <artifactId>jboss-annotations-api_1.2_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
+ http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
+ version="1.1" bean-discovery-mode="annotated">
+</beans>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+ version="2.1">
+ <persistence-unit name="ebeguPersistenceUnit" transaction-type="JTA">
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+ <jta-data-source>java:/jdbc/hmp</jta-data-source>
+ <mapping-file>META-INF/orm.xml</mapping-file>
+ <!--<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>-->
+
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
+ <property name="hibernate.physical_naming_strategy" value="ch.dvbern.demo.persistence.DemoPhysicalNamingStrategyImpl"/>
+
+ <!-- SQL Logging bitte via Logger konfigurieren -->
+ <property name="hibernate.show_sql" value="true"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>ch.dvbern.demo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>Multimodule Project</name>
+
+
+ <properties>
+ <!-- local database properties -->
+ <database.jdbc.driver>org.mariadb.jdbc.Driver</database.jdbc.driver>
+ <database.jdbc.url>jdbc:mysql://localhost/hmp</database.jdbc.url>
+ <database.jdbc.usr>test</database.jdbc.usr>
+ <database.jdbc.pwd>test</database.jdbc.pwd>
+
+ <version.mysqldriver>1.3.7</version.mysqldriver>
+ <version.hibernate>5.1.0.Final</version.hibernate>
+
+ <version.slf4j>1.7.10</version.slf4j>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.wildfly.bom</groupId>
+ <artifactId>jboss-javaee-7.0-wildfly</artifactId>
+ <version>10.0.0.CR2</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${version.hibernate}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>annotations</artifactId>
+ <version>3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>19.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version.hibernate}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>${version.mysqldriver}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.10</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <!-- Submodule-dependencies should be on the project version -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>shared</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-ext</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+
+ <!--hibernate 5 mit java 8 support-->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-java8</artifactId>
+ <version>${version.hibernate}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>annotations</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+
+ <modules>
+ <module>shared</module>
+ <module>ejb</module>
+ </modules>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <groupId>ch.dvbern.demo</groupId>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>shared</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.2_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${version.hibernate}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ </dependency>
+
+ <!--fuer @ForeignKey-->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <!-- Fuer IntelliJ -->
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>${version.hibernate}</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <!--java 8 support fuer hibernate (LocalDate)-->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-java8</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- metamodel generierung, kann eigentlich auch vom compiler plugin gemacht werden aber es gab da einen bug-->
+ <plugin>
+ <groupId>org.bsc.maven</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ <version>2.2.4</version>
+ <executions>
+ <execution>
+ <id>process</id>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <processors>
+ <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
+ </processors>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>${version.hibernate}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!--Der verwendete Dialekt fuer die Schema generierung-->
+ <dialect>org.hibernate.dialect.MySQL5Dialect</dialect>
+ <physicalNamingStrategy>ch.dvbern.demo.persistence.DemoPhysicalNamingStrategyImpl
+ </physicalNamingStrategy>
+ <!--verhindert, dass das Plugin versucht das schema physisch in eine DB zu schreiben-->
+ <export>false</export>
+ <format>true</format>
+ <force>true</force>
+ <!--File in welches das Schema exportiert wird (defaultist create.sql)-->
+ <outputFile>${project.build.directory}/schema.ddl</outputFile>
+ <!--definiert ob der text fuer das sql-schema in die console geloggt wird-->
+ <show>true</show>
+
+ <!--<driver>${database.jdbc.driver}</driver>-->
+ <!--<url>${database.jdbc.url}</url>-->
+ <!--<username>${database.jdbc.usr}</username>-->
+ <!--<password>${database.jdbc.pwd}</password>-->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package ch.dvbern.demo.entities;
+
+import java.io.Serializable;
+import java.util.Objects;
+import java.util.UUID;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Version;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.hibernate.Hibernate;
+
+import ch.dvbern.demo.util.Constants;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+@SuppressWarnings("ClassReferencesSubclass")
+@MappedSuperclass
+public abstract class AbstractEntity implements Serializable {
+
+ private static final long serialVersionUID = -979317154050183445L;
+
+ @Id
+ @Column(unique = true, nullable = false, updatable = false, length = Constants.UUID_LENGTH)
+ @Size(min = Constants.UUID_LENGTH, max = Constants.UUID_LENGTH)
+ private String id;
+
+ @Version
+ @NotNull
+ private long version;
+
+ @Size(max = Constants.UUID_LENGTH)
+ @Column(nullable = false, length = Constants.UUID_LENGTH)
+ private String userErstellt;
+
+ @Size(max = Constants.UUID_LENGTH)
+ @Column(nullable = false, length = Constants.UUID_LENGTH)
+ private String userMutiert;
+
+ protected AbstractEntity() {
+ //da wir teilweise schon eine id brauchen bevor die Entities gespeichert werden initialisieren wir die uuid hier
+ id = UUID.randomUUID().toString();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ // Nullable, da erst im PrePersist gesetzt
+ public long getVersion() {
+ return version;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+
+ @Nullable // Nullable, da erst im PrePersist gesetzt
+ public String getUserErstellt() {
+ return userErstellt;
+ }
+
+ public void setUserErstellt(@Nonnull String userErstellt) {
+ this.userErstellt = userErstellt;
+ }
+
+ @Nullable // Nullable, da erst im PrePersist gesetzt
+ public String getUserMutiert() {
+ return userMutiert;
+ }
+
+ public void setUserMutiert(@Nonnull String userMutiert) {
+ this.userMutiert = userMutiert;
+ }
+
+ @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
+ @SuppressFBWarnings(value = "BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS", justification = "Es wird Hibernate.getClass genutzt um von Proxies (LazyInit) die konkrete Klasse zu erhalten")
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
+ return false;
+ }
+
+ AbstractEntity that = (AbstractEntity) o;
+
+ Objects.requireNonNull(getId());
+ Objects.requireNonNull(that.getId());
+
+ return getId().equals(that.getId());
+ }
+
+ public int hashCode() {
+ return getId() != null ? getId().hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", getId())
+ .toString();
+ }
+}
--- /dev/null
+package ch.dvbern.demo.entities;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.ManyToMany;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import ch.dvbern.demo.util.Constants;
+
+/**
+ * Entitaet zum Speichern von Adressen in der Datenbank.
+ */
+@Entity
+public class Adresse extends AbstractEntity {
+
+ private static final long serialVersionUID = -7687645920281069260L;
+
+ @Size(max = Constants.DB_DEFAULT_MAX_LENGTH)
+ @Nonnull
+ @NotNull
+ @Column(nullable = false, length = Constants.DB_DEFAULT_MAX_LENGTH)
+ private String strasse = "";
+
+ @Size(max = Constants.DB_DEFAULT_SHORT_LENGTH)
+ @Nullable
+ @Column(nullable = true, length = Constants.DB_DEFAULT_SHORT_LENGTH)
+ private String hausnummer = null;
+
+ @Size(max = Constants.DB_DEFAULT_MAX_LENGTH)
+ @Nullable
+ @Column(nullable = true, length = Constants.DB_DEFAULT_MAX_LENGTH)
+ private String zusatzzeile = null;
+
+ @Size(max = Constants.DB_DEFAULT_SHORT_LENGTH)
+ @Nonnull
+ @NotNull
+ @Column(nullable = false, length = Constants.DB_DEFAULT_SHORT_LENGTH)
+ private String plz = "";
+
+ @Size(max = Constants.DB_DEFAULT_MAX_LENGTH)
+ @Nonnull
+ @NotNull
+ @Column(nullable = false, length = Constants.DB_DEFAULT_MAX_LENGTH)
+ private String ort = "";
+
+ @ManyToMany(mappedBy = "adressen")
+ private List<Person> personen = new ArrayList<>();
+
+ @Nonnull
+ public String getStrasse() {
+ return strasse;
+ }
+
+ public void setStrasse(@Nonnull final String strasse) {
+ this.strasse = strasse;
+ }
+
+ @Nullable
+ public String getHausnummer() {
+ return hausnummer;
+ }
+
+ public void setHausnummer(@Nullable final String hausnummer) {
+ this.hausnummer = hausnummer;
+ }
+
+ @Nullable
+ public String getZusatzzeile() {
+ return zusatzzeile;
+ }
+
+ public void setZusatzzeile(@Nullable final String zusatzzeile) {
+ this.zusatzzeile = zusatzzeile;
+ }
+
+ @Nonnull
+ public String getPlz() {
+ return plz;
+ }
+
+ public void setPlz(@Nonnull final String plz) {
+ this.plz = plz;
+ }
+
+ @Nonnull
+ public String getOrt() {
+ return ort;
+ }
+
+ public void setOrt(@Nonnull final String ort) {
+ this.ort = ort;
+ }
+
+ public List<Person> getPersonen() {
+ return personen;
+ }
+
+ public void setPersonen(final List<Person> personen) {
+ this.personen = personen;
+ }
+}
--- /dev/null
+package ch.dvbern.demo.entities;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.ForeignKey;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import static ch.dvbern.demo.util.Constants.DB_DEFAULT_MAX_LENGTH;
+
+/**
+ * Entity fuer personendaten
+ */
+@Entity
+@Table(uniqueConstraints = {
+ @UniqueConstraint(name = "person_uc1", columnNames = "vorname"),
+ @UniqueConstraint(name = "person_uc2", columnNames = "userErstellt"),
+ @UniqueConstraint(name = "person_uc3", columnNames = { "userErstellt", "vorname" }) // FIXME funktioniert nicht
+})
+public class Person extends AbstractEntity {
+
+ private static final long serialVersionUID = -9032257320578372570L;
+
+ @Nonnull
+ @Size(min = 1, max = DB_DEFAULT_MAX_LENGTH)
+ @Column(nullable = false)
+ @NotNull
+ private String vorname = "";
+
+ @Nonnull
+ @Size(min = 1, max = DB_DEFAULT_MAX_LENGTH)
+ @NotNull
+ @Column(nullable = false)
+ private String nachname = "";
+
+ @Nonnull
+ @ManyToMany
+ @JoinTable(
+ name = "personen_adressen",
+ joinColumns = @JoinColumn(name = "person_id", foreignKey = @ForeignKey(name = "person_fk1")),
+ inverseJoinColumns = @JoinColumn(name = "adresse_id", foreignKey = @ForeignKey(name = "adresse_fk1")),
+ indexes = {
+ @Index(name = "personen_adressen_ix1", columnList = "person_id"),
+ @Index(name = "personen_adressen_ix2", columnList = "adresse_id")
+ }
+ )
+// @org.hibernate.annotations.ForeignKey(name = "person_fk1", inverseName = "adresse_fk1") // TODO ohne die Hibernate spez. Annotation funktioniert das Naming der Foreign Keys nicht
+ private List<Adresse> adressen = new ArrayList<>();
+
+
+ @Nonnull
+ public String getVorname() {
+ return vorname;
+ }
+
+ public void setVorname(@Nonnull final String vorname) {
+ this.vorname = vorname;
+ }
+
+ @Nonnull
+ public String getNachname() {
+ return nachname;
+ }
+
+ public void setNachname(@Nonnull final String nachname) {
+ this.nachname = nachname;
+ }
+
+ @Nonnull
+ public List<Adresse> getAdressen() {
+ return adressen;
+ }
+
+ public void setAdressen(@Nonnull final List<Adresse> adressen) {
+ this.adressen = adressen;
+ }
+}
--- /dev/null
+package ch.dvbern.demo.persistence;
+
+import java.util.Locale;
+
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+
+public class DemoPhysicalNamingStrategyImpl extends PhysicalNamingStrategyStandardImpl {
+
+ private static final long serialVersionUID = 7069586216789441113L;
+
+ public static final DemoPhysicalNamingStrategyImpl INSTANCE = new DemoPhysicalNamingStrategyImpl();
+
+ @Override
+ public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
+ return new Identifier(addUnderscores(name.getText()), name.isQuoted());
+ }
+
+ @Override
+ public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) {
+ return new Identifier(addUnderscores(name.getText()), name.isQuoted());
+ }
+
+
+ protected static String addUnderscores(String name) {
+ final StringBuilder buf = new StringBuilder(name.replace('.', '_'));
+ for (int i = 1; i < buf.length() - 1; i++) {
+ if (Character.isLowerCase(buf.charAt(i - 1)) && Character.isUpperCase(buf.charAt(i))
+ && Character.isLowerCase(buf.charAt(i + 1))) {
+ buf.insert(i++, '_');
+ }
+ }
+ return buf.toString().toLowerCase(Locale.ROOT);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 DV Bern AG, Switzerland
+ *
+ * Das vorliegende Dokument, einschliesslich aller seiner Teile, ist urheberrechtlich
+ * geschuetzt. Jede Verwertung ist ohne Zustimmung der DV Bern AG unzulaessig. Dies gilt
+ * insbesondere fuer Vervielfaeltigungen, die Einspeicherung und Verarbeitung in
+ * elektronischer Form. Wird das Dokument einem Kunden im Rahmen der Projektarbeit zur
+ * Ansicht uebergeben ist jede weitere Verteilung durch den Kunden an Dritte untersagt.
+ */
+
+package ch.dvbern.demo.util;
+
+/**
+ * Interface fuer Konstanten.
+ */
+public interface Constants {
+
+ int DB_DEFAULT_MAX_LENGTH = 255;
+ int DB_DEFAULT_SHORT_LENGTH = 100;
+
+ int UUID_LENGTH = 36;
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"
+ version="2.1">
+ <entity class="ch.dvbern.demo.entities.Adresse"/>
+ <entity class="ch.dvbern.demo.entities.Person"/>
+
+</entity-mappings>