dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33458
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17076: Added custom hibernate H2 dialect to avoid error messes in logs during unit testing
------------------------------------------------------------
revno: 17076
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-13 15:37:50 +0200
message:
Added custom hibernate H2 dialect to avoid error messes in logs during unit testing
added:
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect/
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect/DhisH2Dialect.java
modified:
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/dialect/StatementDialectFactoryBean.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect'
=== added file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect/DhisH2Dialect.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect/DhisH2Dialect.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect/DhisH2Dialect.java 2014-10-13 13:37:50 +0000
@@ -0,0 +1,49 @@
+package org.hisp.dhis.hibernate.dialect;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hibernate.dialect.H2Dialect;
+
+public class DhisH2Dialect
+ extends H2Dialect
+{
+ @Override
+ public String getDropSequenceString( String sequenceName )
+ {
+ // Adding the "if exists" clause to avoid warnings
+ return "drop sequence if exists " + sequenceName;
+ }
+
+ @Override
+ public boolean dropConstraints()
+ {
+ // No need to drop constraints before dropping tables, leads to error messages
+ return false;
+ }
+}
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties 2014-07-07 06:44:19 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties 2014-10-13 13:37:50 +0000
@@ -10,7 +10,8 @@
# H2 In-Memory setup
-hibernate.dialect = org.hibernate.dialect.H2Dialect
+# hibernate.dialect = org.hibernate.dialect.H2Dialect
+hibernate.dialect = org.hisp.dhis.hibernate.dialect.DhisH2Dialect
hibernate.connection.driver_class = org.h2.Driver
hibernate.connection.url = jdbc:h2:mem:dhis2;DB_CLOSE_DELAY=-1;MVCC=TRUE;ALIAS_COLUMN_NAME=TRUE;DB_CLOSE_ON_EXIT=FALSE
hibernate.connection.username = sa
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/dialect/StatementDialectFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/dialect/StatementDialectFactoryBean.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/dialect/StatementDialectFactoryBean.java 2014-10-13 13:37:50 +0000
@@ -51,8 +51,9 @@
dialectMap = new HashMap<>();
dialectMap.put( "org.hibernate.dialect.MySQLDialect", StatementDialect.MYSQL );
dialectMap.put( "org.hibernate.dialect.PostgreSQLDialect", StatementDialect.POSTGRESQL );
+ dialectMap.put( "org.hibernate.dialect.HSQLDialect", StatementDialect.HSQL );
dialectMap.put( "org.hibernate.dialect.H2Dialect", StatementDialect.H2 );
- dialectMap.put( "org.hibernate.dialect.HSQLDialect", StatementDialect.HSQL );
+ dialectMap.put( "org.hisp.dhis.hibernate.dialect.DhisH2Dialect",StatementDialect.H2 );
}
// -------------------------------------------------------------------------