Skip to content
Snippets Groups Projects
Commit e7168bec authored by Goik Martin's avatar Goik Martin
Browse files

Streamligning to Archetype

parent 3e29bca5
No related branches found
No related tags found
No related merge requests found
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.hdm-stuttgart.mi</groupId>
<artifactId>lecturenotes-pom</artifactId>
<version>1.0</version>
<relativePath>../../../../pom.xml</relativePath>
</parent>
<groupId>de.hdm-stuttgart.mi.sda1</groupId>
<artifactId>rdbms2catalog</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>rdbms2catalogJpa</name>
<url>http://www.mi.hdm-stuttgart.de/freedocs</url>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.0.CR1</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.0.0.CR1</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>${org.jdom.jdom2.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.mysql-connector-java.version}</version>
</dependency>
</dependencies>
</project>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.hdm-stuttgart.mi</groupId>
<artifactId>lecturenotes-pom</artifactId>
<version>1.0</version>
<relativePath>../../../../pom.xml</relativePath>
</parent>
<groupId>de.hdm-stuttgart.mi.sda1</groupId>
<artifactId>rdbms2catalog</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>rdbms2catalogJpa</name>
<url>http://www.mi.hdm-stuttgart.de/freedocs</url>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.mysql-connector-java.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>${org.jdom.jdom2.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<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>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -18,7 +18,7 @@ public class RdbmsAccess {
static final EntityManager em;
static {
final EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("none");
final EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("update");
em = emFactory.createEntityManager();
}
......@@ -35,6 +35,8 @@ public class RdbmsAccess {
final Element productElement = new Element("product");
root.addContent(productElement);
productElement.setAttribute("id", "" + p.getId());
System.out.println(p.getName() + "++++++++++++++++++++++++++++++++++++");
productElement.addContent(new Element("name").addContent(p.getName()));
......@@ -45,5 +47,6 @@ public class RdbmsAccess {
p.getAge().ifPresent(age -> productElement.addContent(new Element("age").addContent(age.toString())));
}
transaction.commit();
em.getEntityManagerFactory().close();
}
}
\ No newline at end of file
......@@ -7,18 +7,21 @@ import javax.persistence.Embeddable;
@Embeddable
public class Description {
protected Description() {}
public Description(final String description) {
this.description = description;
}
String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
protected Description() {
}
public Description(final String description) {
setDescription(description);
}
String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
\ No newline at end of file
......@@ -12,6 +12,10 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OrderColumn;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
@Entity
public class Product {
......
......@@ -3,53 +3,51 @@
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="create-drop" transaction-type="RESOURCE_LOCAL">
<persistence-unit name="drop-create" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/hdm" />
<property name="javax.persistence.jdbc.user" value="hdmuser" />
<property name="javax.persistence.jdbc.password" value="XYZ" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hdm?useSSL=false"/>
<property name="javax.persistence.jdbc.user" value="hdmuser"/>
<property name="javax.persistence.jdbc.password" value="XYZ"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property
name="javax.persistence.schema-generation.database.action"
value="drop-and-create"/>
<!-- Configuring Connection Pool -->
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="500" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="2000" />
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
<persistence-unit name="none" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<persistence-unit name="update" transaction-type="RESOURCE_LOCAL">
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/hdm" />
<property name="javax.persistence.jdbc.user" value="hdmuser" />
<property name="javax.persistence.jdbc.password" value="XYZ" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hdm?useSSL=false"/>
<property name="javax.persistence.jdbc.user" value="hdmuser"/>
<property name="javax.persistence.jdbc.password" value="XYZ"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="none" />
<property
name="javax.persistence.schema-generation.database.action"
value="update"/>
<!-- Configuring Connection Pool -->
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="500" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="2000" />
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
......
......@@ -15,7 +15,7 @@ public class TestSchema {
static final EntityManager em;
static {
final EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("create-drop");
final EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("drop-create");
em = emFactory.createEntityManager();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment