HHH-5200 - Prepare to use H2 as the default testing datbase

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19429 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-05-08 21:58:15 +00:00
parent 413666f293
commit b4fa90a58b
5 changed files with 41 additions and 23 deletions

View File

@ -114,8 +114,18 @@ public class SettingsFactory implements Serializable {
Connection conn = connections.getConnection(); Connection conn = connections.getConnection();
try { try {
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
log.info( "RDBMS: " + meta.getDatabaseProductName() + ", version: " + meta.getDatabaseProductVersion() ); log.info( "Database ->\n" +
log.info( "JDBC driver: " + meta.getDriverName() + ", version: " + meta.getDriverVersion() ); " name : " + meta.getDatabaseProductName() + '\n' +
" version : " + meta.getDatabaseProductVersion() + '\n' +
" major : " + meta.getDatabaseMajorVersion() + '\n' +
" minor : " + meta.getDatabaseMinorVersion()
);
log.info( "Driver ->\n" +
" name : " + meta.getDriverName() + '\n' +
" version : " + meta.getDriverVersion() + '\n' +
" major : " + meta.getDriverMajorVersion() + '\n' +
" minor : " + meta.getDriverMinorVersion()
);
dialect = DialectFactory.buildDialect( props, conn ); dialect = DialectFactory.buildDialect( props, conn );
jdbcSupport = JdbcSupportLoader.loadJdbcSupport( conn ); jdbcSupport = JdbcSupportLoader.loadJdbcSupport( conn );

View File

@ -592,7 +592,7 @@
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>1.2.124</version> <version>1.2.134</version>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>

View File

@ -185,12 +185,14 @@ public class WithClauseTest extends FunctionalTestCase {
public void cleanup() { public void cleanup() {
Session session = openSession(); Session session = openSession();
Transaction txn = session.beginTransaction(); Transaction txn = session.beginTransaction();
session.createQuery( "delete Animal where mother is not null" ).executeUpdate(); Human father = (Human) session.createQuery( "from Human where description = 'father'" ).uniqueResult();
List humansWithFriends = session.createQuery( "from Human h where exists(from h.friends)" ).list(); father.getFriends().clear();
Iterator itr = humansWithFriends.iterator(); session.flush();
while ( itr.hasNext() ) { session.delete( session.createQuery( "from Human where description = 'friend'" ).uniqueResult() );
session.delete( itr.next() ); session.delete( session.createQuery( "from Human where description = 'child1'" ).uniqueResult() );
} session.delete( session.createQuery( "from Human where description = 'child2'" ).uniqueResult() );
session.delete( session.createQuery( "from Human where description = 'mother'" ).uniqueResult() );
session.delete( father );
session.createQuery( "delete Animal" ).executeUpdate(); session.createQuery( "delete Animal" ).executeUpdate();
txn.commit(); txn.commit();
session.close(); session.close();

View File

@ -74,7 +74,7 @@ public class JPALockTest extends AbstractJPATest {
Long itemId = item.getId(); Long itemId = item.getId();
// doAfterTransactionCompletion the isolated update // do the isolated update
s1 = getSessions().openSession(); s1 = getSessions().openSession();
t1 = s1.beginTransaction(); t1 = s1.beginTransaction();
item = (Item) s1.get( Item.class, itemId ); item = (Item) s1.get( Item.class, itemId );

View File

@ -8,6 +8,7 @@ import java.util.List;
import junit.framework.Test; import junit.framework.Test;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.id.PostInsertIdentifierGenerator;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite; import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.classic.Session; import org.hibernate.classic.Session;
import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.HSQLDialect;
@ -31,10 +32,15 @@ public class CustomSQLTest extends LegacyTestCase {
return new FunctionalTestClassTestSuite( CustomSQLTest.class ); return new FunctionalTestClassTestSuite( CustomSQLTest.class );
} }
public void testInsert() throws HibernateException, SQLException { private boolean isUsingIdentity() {
return PostInsertIdentifierGenerator.class.isAssignableFrom( getDialect().getNativeIdentifierGeneratorClass() );
}
if ( getDialect() instanceof HSQLDialect ) return; public void testInsert() throws HibernateException, SQLException {
if ( getDialect() instanceof MySQLDialect ) return; if ( isUsingIdentity() ) {
reportSkip( "hand sql expecting non-identity id gen", "Custom SQL" );
return;
}
Role p = new Role(); Role p = new Role();
@ -93,9 +99,10 @@ public class CustomSQLTest extends LegacyTestCase {
} }
public void testCollectionCUD() throws HibernateException, SQLException { public void testCollectionCUD() throws HibernateException, SQLException {
if ( isUsingIdentity() ) {
if ( getDialect() instanceof HSQLDialect ) return; reportSkip( "hand sql expecting non-identity id gen", "Custom SQL" );
if ( getDialect() instanceof MySQLDialect ) return; return;
}
Role role = new Role(); Role role = new Role();
@ -155,9 +162,10 @@ public class CustomSQLTest extends LegacyTestCase {
} }
public void testCRUD() throws HibernateException, SQLException { public void testCRUD() throws HibernateException, SQLException {
if ( isUsingIdentity() ) {
if ( getDialect() instanceof HSQLDialect ) return; reportSkip( "hand sql expecting non-identity id gen", "Custom SQL" );
if ( getDialect() instanceof MySQLDialect ) return; return;
}
Person p = new Person(); Person p = new Person();
@ -206,7 +214,5 @@ public class CustomSQLTest extends LegacyTestCase {
s.connection().commit(); s.connection().commit();
s.close(); s.close();
} }
} }