HHH-5374 - Upgrade to H2 version 1.2.139

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19952 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-07-14 18:44:11 +00:00
parent f49096641f
commit 04983c2528
3 changed files with 48 additions and 9 deletions

View File

@ -26,6 +26,9 @@ package org.hibernate.dialect;
import java.sql.SQLException;
import java.sql.Types;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.Hibernate;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.AvgWithArgumentCastFunction;
@ -42,6 +45,7 @@ import org.hibernate.util.ReflectHelper;
* @author Thomas Mueller
*/
public class H2Dialect extends Dialect {
private static final Logger log = LoggerFactory.getLogger( H2Dialect.class );
private String querySequenceString;
@ -51,14 +55,22 @@ public class H2Dialect extends Dialect {
querySequenceString = "select sequence_name from information_schema.sequences";
try {
// HHH-2300
Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
Integer build = ( Integer ) constants.getDeclaredField( "BUILD_ID" ).get( null );
int buildid = build.intValue();
if ( buildid < 32 ) {
final Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
final int majorVersion = ( Integer ) constants.getDeclaredField( "VERSION_MAJOR" ).get( null );
final int minorVersion = ( Integer ) constants.getDeclaredField( "VERSION_MINOR" ).get( null );
final int buildId = ( Integer ) constants.getDeclaredField( "BUILD_ID" ).get( null );
if ( buildId < 32 ) {
querySequenceString = "select name from information_schema.sequences";
}
if ( !( majorVersion > 1 || minorVersion > 2 || buildId >= 139 ) ) {
log.warn(
"The {} version of H2 implements temporary table creation such that it commits " +
"current transaction; multi-table, bulk hql/jpaql will not work properly",
( majorVersion + "." + minorVersion + "." + buildId )
);
}
catch ( Throwable e ) {
}
catch ( Exception e ) {
// ignore (probably H2 not in the classpath)
}
@ -279,12 +291,24 @@ public class H2Dialect extends Dialect {
}
};
@Override
public boolean supportsTemporaryTables() {
return true;
}
@Override
public String getCreateTemporaryTableString() {
return "create temporary table if not exists";
return "create local temporary table if not exists";
}
@Override
public Boolean performTemporaryTableDDLInIsolation() {
return Boolean.FALSE;
}
@Override
public boolean dropTemporaryTableAfterUse() {
return false;
}
public boolean supportsCurrentTimestampSelection() {
@ -306,6 +330,7 @@ public class H2Dialect extends Dialect {
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public boolean supportsLobValueChangePropogation() {
return false;
}

View File

@ -542,7 +542,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.2.134</version>
<version>1.2.139</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -5,11 +5,13 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import org.hibernate.QueryException;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.hql.ast.HqlSqlWalker;
import org.hibernate.id.IdentifierGenerator;
@ -824,8 +826,20 @@ public class BulkManipulationTest extends FunctionalTestCase {
count = s.createQuery( "update Vehicle set owner = null where owner = 'Steve'" ).executeUpdate();
assertEquals( "incorrect restricted update count", 4, count );
try {
count = s.createQuery( "delete Vehicle where owner is null" ).executeUpdate();
assertEquals( "incorrect restricted update count", 4, count );
assertEquals( "incorrect restricted delete count", 4, count );
}
catch ( AssertionFailedError afe ) {
if ( H2Dialect.class.isInstance( getDialect() ) ) {
// http://groups.google.com/group/h2-database/t/5548ff9fd3abdb7
count = s.createQuery( "delete Vehicle" ).executeUpdate();
assertEquals( "incorrect count", 4, count );
}
else {
throw afe;
}
}
t.commit();
s.close();