diff --git a/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/pom.xml b/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/pom.xml index 9884efd162439b83e6c27debcf21ea7d92ec22b0..83b0bea702d36a5f74bb1467ebfe1bd436abce70 100644 --- a/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/pom.xml +++ b/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/pom.xml @@ -1,96 +1,93 @@ -<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> - - <groupId>${groupId}</groupId> - <artifactId>${artifactId}</artifactId> - <version>${version}</version> - <packaging>jar</packaging> - - <name>${artifactId}</name> +<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> - <url>http://www.mi.hdm-stuttgart.de/freedocs/topic/de.hdm_stuttgart.mi.lectures/sd1SectUsingMaven.html</url> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <packaging>jar</packaging> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-entitymanager</artifactId> - <version>5.1.0.Final</version> - </dependency> + <name>${artifactId}</name> - <dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>5.1.38</version> - </dependency> + <url>http://www.mi.hdm-stuttgart.de/freedocs/topic/de.hdm_stuttgart.mi.lectures/sd1SectUsingMaven.html</url> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <scope>test</scope> - </dependency> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <version>2.4.1</version> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <version>2.4.1</version> - </dependency> + <dependencies> - </dependencies> - - <build> - <plugins> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>5.1.0.Final</version> + </dependency> - <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> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.38</version> + </dependency> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <version>2.10.3</version> - <configuration/> - </plugin> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>2.4.3</version> - <configuration> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <manifestEntries> - <Main-Class>${package}.App</Main-Class> - </manifestEntries> - </transformer> - </transformers> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.6</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> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.3</version> + <configuration /> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.4.3</version> + <configuration> + <transformers> + <transformer + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <manifestEntries> + <Main-Class>${package}.App</Main-Class> + </manifestEntries> + </transformer> + </transformers> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> </project> diff --git a/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/src/main/java/CreateEntity.java b/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/src/main/java/CreateEntity.java index 2c33b5394fdd8aea454d8f9038a9174a40f382ca..bbc2941efb11a344ad221e6db86bd21781fdf5d8 100644 --- a/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/src/main/java/CreateEntity.java +++ b/ws/Archetypes/mi-maven-archetype-jpa-hibernate/src/main/resources/archetype-resources/src/main/java/CreateEntity.java @@ -7,10 +7,15 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; -import ${package}.model.Airline; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import de.mi.hdm_stuttgart.model.Airline; public class CreateEntity { + static final Logger log = LogManager.getLogger(CreateEntity.class); + // This requires a corresponding entry <persistence-unit name="entitytemplatePU"> // in META-INF/persistence.xml static public final String PERSISTENCE_UNIT_NAME = "entitytemplatePU"; @@ -18,17 +23,19 @@ public class CreateEntity { * @param args Unused */ public static void main( String[] args ) { - + final EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); final EntityManager em = factory.createEntityManager(); + log.info("Begin transaction"); em.getTransaction().begin(); final Airline lh = new Airline("Lufthansa", "DLH"); em.persist(lh); em.getTransaction().commit(); + log.info("Committed transaction"); em.close(); factory.close(); } -} +} \ No newline at end of file