Fixed error-reporting: errors reported by Hibernate are no longer swallowed
authorKai Moritz <kai@juplo.de>
Sun, 6 Nov 2016 16:11:28 +0000 (17:11 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 13 Nov 2016 16:37:15 +0000 (17:37 +0100)
Renamed the H2-databases in the OSGI-tests of the Hibernate-Tutorials,
because it showed, that these tests are failing, but only, if they are
executed together through the parent-directory of the tutorial, but not,
if they are executed separatly, which indicates timing issues in connection
with the shutdown of the database.

src/it/tutorials/osgi/datasource-h2.xml [deleted file]
src/it/tutorials/osgi/managed-jpa/pom.xml
src/it/tutorials/osgi/unmanaged-jpa/src/main/resources/META-INF/persistence.xml
src/it/tutorials/osgi/unmanaged-native/src/main/resources/hibernate.cfg.xml
src/it/tutorials/osgi/unmanaged-native/src/main/resources/pool-one.properties
src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java

diff --git a/src/it/tutorials/osgi/datasource-h2.xml b/src/it/tutorials/osgi/datasource-h2.xml
deleted file mode 100644 (file)
index 76ede3c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-First install the H2 driver using:
-> install -s mvn:com.h2database/h2/1.3.163
-
-Then copy this file to the deploy folder
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-  
-  <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
-      <property name="URL" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
-      <property name="user" value="sa"/>
-      <property name="password" value=""/>
-  </bean>
-  
-  <service interface="javax.sql.DataSource" ref="dataSource">
-    <service-properties>
-            <entry key="osgi.jndi.service.name" value="jdbc/h2ds"/>
-    </service-properties>
-  </service>
-</blueprint>
index b1ac0d8..8c9fa47 100644 (file)
@@ -80,7 +80,7 @@
                                        </execution>
                                </executions>
                                <configuration>
                                        </execution>
                                </executions>
                                <configuration>
-                                       <url>jdbc:h2:mem:db1;MVCC=TRUE</url>
+                                       <url>jdbc:h2:mem:db_managed_jpa;MVCC=TRUE</url>
                                        <format>true</format>
                                        <execute>false</execute>
                                </configuration>
                                        <format>true</format>
                                        <execute>false</execute>
                                </configuration>
index 7c7efca..0483f5c 100644 (file)
@@ -9,10 +9,10 @@
         <properties>
             <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
             <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
         <properties>
             <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
             <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
-            <property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
+            <property name="hibernate.connection.url" value="jdbc:h2:mem:db_unmanaged_jpa;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
             <property name="hibernate.connection.username" value="sa"/>
             <property name="hibernate.connection.password" value=""/>
             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
         </properties>
     </persistence-unit>
             <property name="hibernate.connection.username" value="sa"/>
             <property name="hibernate.connection.password" value=""/>
             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
         </properties>
     </persistence-unit>
-</persistence>
\ No newline at end of file
+</persistence>
index 278f529..f367c53 100644 (file)
@@ -6,7 +6,7 @@
 <hibernate-configuration>
     <session-factory>
         <property name="hibernate.connection.driver_class">org.h2.Driver</property>
 <hibernate-configuration>
     <session-factory>
         <property name="hibernate.connection.driver_class">org.h2.Driver</property>
-        <property name="hibernate.connection.url">jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE</property>
+        <property name="hibernate.connection.url">jdbc:h2:mem:db_unmanaged_native;DB_CLOSE_DELAY=-1;MVCC=TRUE</property>
         <property name="hibernate.connection.username">sa</property>
         <property name="hibernate.connection.password"></property>
         <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
         <property name="hibernate.connection.username">sa</property>
         <property name="hibernate.connection.password"></property>
         <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
index abaee38..0a372bd 100644 (file)
@@ -1,7 +1,7 @@
 jdbc-0.proxool.alias=pool-one
 jdbc-0.proxool.alias=pool-one
-jdbc-0.proxool.driver-url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
+jdbc-0.proxool.driver-url=jdbc:h2:mem:db_unmanaged_native;DB_CLOSE_DELAY=-1;MVCC=TRUE
 jdbc-0.proxool.driver-class=org.h2.Driver
 jdbc-0.user=sa
 jdbc-0.password=
 jdbc-0.proxool.maximum-connection-count=2
 jdbc-0.proxool.driver-class=org.h2.Driver
 jdbc-0.user=sa
 jdbc-0.password=
 jdbc-0.proxool.maximum-connection-count=2
-jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE
\ No newline at end of file
+jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE
index 20c326a..c9ef2c5 100644 (file)
@@ -733,12 +733,23 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
       {
         thread.setContextClassLoader(classLoader);
         build((MetadataImplementor)metadataBuilder.build(), options, target);
       {
         thread.setContextClassLoader(classLoader);
         build((MetadataImplementor)metadataBuilder.build(), options, target);
+        if (handler.getExceptions().size() > 0)
+        {
+          StringBuilder builder = new StringBuilder();
+          builder.append("Hibernate failed:");
+          for (Exception e : handler.getExceptions())
+          {
+            builder.append("\n * ");
+            builder.append(e.getMessage());
+          }
+          String error = builder.toString();
+          getLog().error(error);
+          throw new MojoFailureException(error);
+        }
       }
       finally
       {
         thread.setContextClassLoader(contextClassLoader);
       }
       finally
       {
         thread.setContextClassLoader(contextClassLoader);
-        for (Exception e : handler.getExceptions())
-          getLog().error(e.getMessage());
         /** Track, the content of the generated script */
         checkOutputFile(output, tracker);
       }
         /** Track, the content of the generated script */
         checkOutputFile(output, tracker);
       }