@Override protected void onShutdown(ApplicationEvent event) { // Shut down DB, if required Class<?> dialectClazz = this.dialect.getClass(); if (dialectClazz.equals(DerbyDialect.class)) { try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); } // Derby shutdown always triggers an exception, even when clean catch (Throwable e) { } } }
/** * Determine the Hibernate database dialect class for the given target database. * @param database the target database * @return the Hibernate database dialect class, or {@code null} if none found */ @SuppressWarnings("deprecation") protected Class<?> determineDatabaseDialectClass(Database database) { switch (database) { case DB2: return DB2Dialect.class; case DERBY: return DerbyDialect.class; // DerbyDialect deprecated in 4.x case H2: return H2Dialect.class; case HSQL: return HSQLDialect.class; case INFORMIX: return InformixDialect.class; case MYSQL: return MySQLDialect.class; case ORACLE: return Oracle9iDialect.class; case POSTGRESQL: return PostgreSQLDialect.class; // PostgreSQLDialect deprecated in 4.x case SQL_SERVER: return SQLServerDialect.class; case SYBASE: return org.hibernate.dialect.SybaseDialect.class; // SybaseDialect deprecated in 3.6 but not 4.x default: return null; } }
/** * Determine the Hibernate database dialect class for the given target database. * @param database the target database * @return the Hibernate database dialect class, or {@code null} if none found */ protected Class determineDatabaseDialectClass(Database database) { switch (database) { case DB2: return DB2Dialect.class; case DERBY: return DerbyDialect.class; case H2: return H2Dialect.class; case HSQL: return HSQLDialect.class; case INFORMIX: return InformixDialect.class; case MYSQL: return MySQLDialect.class; case ORACLE: return Oracle9iDialect.class; case POSTGRESQL: return PostgreSQLDialect.class; case SQL_SERVER: return SQLServerDialect.class; case SYBASE: return SybaseDialect.class; default: return null; } }
/** * Does the db/dialect support using a column's physical name in the having clause * even after it has been aliased in the select/group-by clause. This is not actually * required by the SQL spec, although virtually ever DB in the world supports this. * * @param testDescription description of the scenario being tested. * @return true if is allowed */ protected boolean allowsPhysicalColumnNameInHaving(String testDescription) { // I only *know* of this being a limitation on Derby, although I highly suspect // it is a limitation on any IBM/DB2 variant if ( DerbyDialect.class.isInstance( getDialect() ) ) { // https://issues.apache.org/jira/browse/DERBY-1624 reportSkip( "Dialect does not support physical column name in having clause after it is aliased", testDescription ); return false; } return true; }
@Override protected Dialect createHibernateDialect() { return new DerbyDialect(); }