This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit f51c7ce9cb80008b7b56087facf973b0c6df8867
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Tue Mar 10 12:51:33 2026 -0500

    hibernate 7:  cleaning and testing HibernateSpringBeanDatabase
---
 .../database/HibernateClassicDatabase.java         |  29 +-
 .../hibernate/database/HibernateEjb3Database.java  |  65 ++--
 .../database/HibernateSpringBeanDatabase.java      | 137 ++++----
 .../database/HibernateSpringPackageDatabase.java   |   9 +-
 .../hibernate/database/JpaPersistenceDatabase.java |  17 +-
 .../connection/HibernateConnectionMetadata.java    | 365 ++++++++++-----------
 .../database/HibernateSpringDatabaseTest.java      |  23 +-
 7 files changed, 343 insertions(+), 302 deletions(-)

diff --git 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java
 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java
index 58ebc88046..314c3c0302 100644
--- 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java
+++ 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java
@@ -1,5 +1,7 @@
 package liquibase.ext.hibernate.database;
 
+import java.util.Optional;
+
 import liquibase.database.DatabaseConnection;
 import liquibase.exception.DatabaseException;
 import org.hibernate.boot.Metadata;
@@ -17,31 +19,36 @@ public class HibernateClassicDatabase extends 
HibernateDatabase {
 
     protected Configuration configuration;
 
-    public boolean isCorrectDatabaseImplementation(DatabaseConnection conn)  {
-        return conn.getURL().startsWith("hibernate:classic:");
+    @Override
+    public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) {
+        return Optional.ofNullable(conn.getURL())
+                .map(url -> url.startsWith("hibernate:classic:"))
+                .orElse(false);
     }
 
     @Override
     protected String findDialectName() {
-        String dialectName = super.findDialectName();
-
-        if (dialectName == null) {
-            dialectName = configuration.getProperty(AvailableSettings.DIALECT);
-        }
-        return dialectName;
+        return Optional.ofNullable(super.findDialectName())
+                .or(() -> Optional.ofNullable(configuration).map(c -> 
c.getProperty(AvailableSettings.DIALECT)))
+                .orElse(null);
     }
 
+    @Override
     protected Metadata buildMetadataFromPath() throws DatabaseException {
         this.configuration = new Configuration();
-        this.configuration.configure(getHibernateConnection().getPath());
+        String path = Optional.ofNullable(getHibernateConnection().getPath())
+                .orElseThrow(() -> new IllegalStateException("Hibernate 
connection path is null"));
+        this.configuration.configure(path);
 
         return super.buildMetadataFromPath();
     }
 
     @Override
-    protected void configureSources(MetadataSources sources)  {
+    protected void configureSources(MetadataSources sources) {
         Configuration config = new Configuration(sources);
-        config.configure(getHibernateConnection().getPath());
+        String path = Optional.ofNullable(getHibernateConnection().getPath())
+                .orElseThrow(() -> new IllegalStateException("Hibernate 
connection path is null"));
+        config.configure(path);
 
         
config.setProperty(HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, 
Boolean.FALSE.toString());
         config.setProperty("hibernate.cache.use_second_level_cache", "false");
diff --git 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateEjb3Database.java
 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateEjb3Database.java
index e168de3745..46e189d9a4 100644
--- 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateEjb3Database.java
+++ 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateEjb3Database.java
@@ -1,8 +1,10 @@
 package liquibase.ext.hibernate.database;
 
 import java.lang.reflect.Field;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 
 import jakarta.persistence.EntityManagerFactory;
 import jakarta.persistence.PersistenceUnitTransactionType;
@@ -38,8 +40,10 @@ public class HibernateEjb3Database extends HibernateDatabase 
{
     }
 
     @Override
-    public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) 
throws DatabaseException {
-        return conn.getURL().startsWith("hibernate:ejb3:");
+    public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) {
+        return Optional.ofNullable(conn.getURL())
+                .map(url -> url.startsWith("hibernate:ejb3:"))
+                .orElse(false);
     }
 
     /**
@@ -47,18 +51,16 @@ public class HibernateEjb3Database extends 
HibernateDatabase {
      */
     @Override
     protected Metadata buildMetadataFromPath() throws DatabaseException {
-
         EntityManagerFactoryBuilderImpl builder = 
createEntityManagerFactoryBuilder();
-
         this.entityManagerFactory = builder.build();
-
         Metadata metadata = builder.getMetadata();
 
         String dialectString = findDialectName();
         if (dialectString != null) {
             try {
-                dialect = (Dialect)
-                        
Class.forName(dialectString).getDeclaredConstructor().newInstance();
+                dialect = (Dialect) Class.forName(dialectString)
+                        .getDeclaredConstructor()
+                        .newInstance();
                 Scope.getCurrentScope().getLog(getClass()).info("Using dialect 
" + dialectString);
             } catch (Exception e) {
                 throw new DatabaseException(e);
@@ -83,32 +85,27 @@ public class HibernateEjb3Database extends 
HibernateDatabase {
                 AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA,
                 
getProperty(AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA));
 
+        String path = Optional.ofNullable(getHibernateConnection().getPath())
+                .orElseThrow(() -> new IllegalStateException("Hibernate 
connection path is null"));
+
         return (EntityManagerFactoryBuilderImpl) 
persistenceProvider.getEntityManagerFactoryBuilderOrNull(
-                getHibernateConnection().getPath(), properties, null);
+                path, properties, null);
     }
 
     @Override
     public String getProperty(String name) {
-        String property = null;
-        if (entityManagerFactory != null) {
-            property = (String) entityManagerFactory.getProperties().get(name);
-        }
-
-        if (property == null) {
-            return super.getProperty(name);
-        } else {
-            return property;
-        }
+        return Optional.ofNullable(entityManagerFactory)
+                .map(emf -> (String) emf.getProperties().get(name))
+                .or(() -> Optional.ofNullable(super.getProperty(name)))
+                .orElse(null);
     }
 
     @Override
     protected String findDialectName() {
-        String dialectName = super.findDialectName();
-        if (dialectName != null) {
-            return dialectName;
-        }
-
-        return (String) 
entityManagerFactory.getProperties().get(AvailableSettings.DIALECT);
+        return Optional.ofNullable(super.findDialectName())
+                .or(() -> Optional.ofNullable(entityManagerFactory)
+                        .map(emf -> (String) 
emf.getProperties().get(AvailableSettings.DIALECT)))
+                .orElse(null);
     }
 
     /**
@@ -116,18 +113,14 @@ public class HibernateEjb3Database extends 
HibernateDatabase {
      */
     @Override
     protected void configureSources(MetadataSources sources) {
-        for (ManagedType<?> managedType : 
entityManagerFactory.getMetamodel().getManagedTypes()) {
-            Class<?> javaType = managedType.getJavaType();
-            if (javaType == null) {
-                continue;
-            }
-            sources.addAnnotatedClass(javaType);
-        }
-
-        Package[] packages = Package.getPackages();
-        for (Package p : packages) {
-            sources.addPackage(p);
-        }
+        Optional.ofNullable(entityManagerFactory)
+                .map(EntityManagerFactory::getMetamodel)
+                .ifPresent(metamodel -> metamodel.getManagedTypes().stream()
+                        .map(ManagedType::getJavaType)
+                        .filter(java.util.Objects::nonNull)
+                        .forEach(sources::addAnnotatedClass));
+
+        Arrays.stream(Package.getPackages()).forEach(sources::addPackage);
     }
 
     private static class MyHibernatePersistenceProvider extends 
HibernatePersistenceProvider {
diff --git 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringBeanDatabase.java
 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringBeanDatabase.java
index 7eefda310f..7212c62614 100644
--- 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringBeanDatabase.java
+++ 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringBeanDatabase.java
@@ -1,9 +1,11 @@
 package liquibase.ext.hibernate.database;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.List;
-import java.util.Map;
+import java.util.Optional;
 import java.util.Properties;
+import java.util.stream.Stream;
 
 import liquibase.Scope;
 import liquibase.database.DatabaseConnection;
@@ -34,8 +36,11 @@ public class HibernateSpringBeanDatabase extends 
HibernateDatabase {
     private BeanDefinition beanDefinition;
     private ManagedProperties beanDefinitionProperties;
 
+    @Override
     public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) {
-        return conn.getURL().startsWith("hibernate:spring:");
+        return Optional.ofNullable(conn.getURL())
+                .map(url -> url.startsWith("hibernate:spring:"))
+                .orElse(false);
     }
 
     /**
@@ -49,97 +54,113 @@ public class HibernateSpringBeanDatabase extends 
HibernateDatabase {
 
     @Override
     public String getProperty(String name) {
-        String value = super.getProperty(name);
-        if (value == null && beanDefinitionProperties != null) {
-            for (Map.Entry entry : ((ManagedProperties) beanDefinition
-                            .getPropertyValues()
-                            .getPropertyValue("hibernateProperties")
-                            .getValue())
-                    .entrySet()) {
-                if (entry.getKey() instanceof TypedStringValue && 
entry.getValue() instanceof TypedStringValue) {
-                    if (((TypedStringValue) 
entry.getKey()).getValue().equals(name)) {
-                        return ((TypedStringValue) 
entry.getValue()).getValue();
-                    }
-                }
-            }
+        return Optional.ofNullable(super.getProperty(name))
+                .or(() -> findPropertyInBeanDefinition(name))
+                .orElseGet(() -> beanDefinitionProperties != null ? 
beanDefinitionProperties.getProperty(name) : null);
+    }
 
-            value = beanDefinitionProperties.getProperty(name);
+    private Optional<String> findPropertyInBeanDefinition(String name) {
+        return Optional.ofNullable(beanDefinitionProperties)
+                .flatMap(props -> props.entrySet().stream()
+                        .filter(entry -> 
name.equals(resolveString(entry.getKey())))
+                        .map(entry -> resolveString(entry.getValue()))
+                        .filter(java.util.Objects::nonNull)
+                        .findFirst());
+    }
+
+    private String resolveString(Object obj) {
+        if (obj instanceof TypedStringValue tsv) {
+            return tsv.getValue();
+        } else if (obj instanceof String s) {
+            return s;
         }
-        return value;
+        return null;
     }
 
     /**
      * Parse the given URL assuming it is a spring XML file
      */
-    protected void loadBeanDefinition() throws DatabaseException {
+    protected void loadBeanDefinition() {
         // Read configuration
         BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
         XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
         reader.setNamespaceAware(true);
         HibernateConnection connection = getHibernateConnection();
-        reader.loadBeanDefinitions(new 
ClassPathResource(connection.getPath()));
-
-        Properties props = connection.getProperties();
+        String path = Optional.ofNullable(connection.getPath())
+                .orElseThrow(() -> new IllegalStateException("Hibernate 
connection path is null"));
+        reader.loadBeanDefinitions(new ClassPathResource(path));
 
-        String beanName = props.getProperty("bean", null);
+        Properties props = Optional.ofNullable(connection.getProperties())
+                .orElseThrow(() -> new IllegalStateException("Hibernate 
connection properties are null"));
 
-        if (beanName == null) {
-            throw new IllegalStateException("A 'bean' name is required, 
definition in '" + connection.getPath() + "'.");
-        }
+        String beanName = Optional.ofNullable(props.getProperty("bean"))
+                .orElseThrow(() -> new IllegalStateException("A 'bean' name is 
required, definition in '" + path + "'."));
 
         try {
             beanDefinition = registry.getBeanDefinition(beanName);
-            var hibernatePropertiesValue = 
beanDefinition.getPropertyValues().getPropertyValue("hibernateProperties");
-            if (hibernatePropertiesValue != null) {
-                beanDefinitionProperties = (ManagedProperties) 
hibernatePropertiesValue.getValue();
-            }
+            
Optional.ofNullable(beanDefinition.getPropertyValues().getPropertyValue("hibernateProperties"))
+                    .map(PropertyValue::getValue)
+                    .filter(ManagedProperties.class::isInstance)
+                    .map(ManagedProperties.class::cast)
+                    .ifPresent(p -> beanDefinitionProperties = p);
         } catch (NoSuchBeanDefinitionException e) {
             throw new IllegalStateException(
-                    "A bean named '" + beanName + "' could not be found in '" 
+ connection.getPath() + "'.");
+                    "A bean named '" + beanName + "' could not be found in '" 
+ path + "'.", e);
         }
     }
 
     @Override
     protected void configureSources(MetadataSources sources) throws 
DatabaseException {
-        MutablePropertyValues properties = beanDefinition.getPropertyValues();
+        BeanDefinition bd = Optional.ofNullable(beanDefinition)
+                .orElseThrow(() -> new DatabaseException("Bean definition is 
not loaded."));
+        MutablePropertyValues properties = bd.getPropertyValues();
 
         // Add annotated classes list.
-        PropertyValue annotatedClassesProperty = 
properties.getPropertyValue("annotatedClasses");
-        if (annotatedClassesProperty != null) {
-            List<TypedStringValue> annotatedClasses = (List<TypedStringValue>) 
annotatedClassesProperty.getValue();
-            if (annotatedClasses != null) {
-                for (TypedStringValue className : annotatedClasses) {
-                    Scope.getCurrentScope().getLog(getClass()).info("Found 
annotated class " + className.getValue());
-                    sources.addAnnotatedClass(findClass(className.getValue()));
-                }
-            }
-        }
+        extractListProperty(properties, "annotatedClasses")
+                .forEach(className -> {
+                    Scope.getCurrentScope().getLog(getClass()).info("Found 
annotated class " + className);
+                    sources.addAnnotatedClass(findClass(className));
+                });
 
         try {
             // Add mapping locations
-            PropertyValue mappingLocationsProp = 
properties.getPropertyValue("mappingLocations");
-            if (mappingLocationsProp != null) {
-                List<TypedStringValue> mappingLocations = 
(List<TypedStringValue>) mappingLocationsProp.getValue();
-                if (mappingLocations != null) {
-                    ResourcePatternResolver resourcePatternResolver = new 
PathMatchingResourcePatternResolver();
-                    for (TypedStringValue mappingLocation : mappingLocations) {
-                        Scope.getCurrentScope()
-                                .getLog(getClass())
-                                .info("Found mappingLocation " + 
mappingLocation.getValue());
-                        Resource[] resources = 
resourcePatternResolver.getResources(mappingLocation.getValue());
-                        for (Resource resource : resources) {
-                            URL url = resource.getURL();
-                            
Scope.getCurrentScope().getLog(getClass()).info("Adding resource  " + url);
-                            sources.addURL(url);
+            ResourcePatternResolver resourcePatternResolver = new 
PathMatchingResourcePatternResolver();
+            extractListProperty(properties, "mappingLocations")
+                    .forEach(mappingLocation -> {
+                        try {
+                            
Scope.getCurrentScope().getLog(getClass()).info("Found mappingLocation " + 
mappingLocation);
+                            Resource[] resources = 
resourcePatternResolver.getResources(mappingLocation);
+                            if (resources != null) {
+                                for (Resource resource : resources) {
+                                    URL url = resource.getURL();
+                                    if (url != null) {
+                                        
Scope.getCurrentScope().getLog(getClass()).info("Adding resource  " + url);
+                                        sources.addURL(url);
+                                    }
+                                }
+                            }
+                        } catch (IOException e) {
+                            throw new RuntimeException(e);
                         }
-                    }
-                }
-            }
+                    });
         } catch (Exception e) {
             throw new DatabaseException(e);
         }
     }
 
+    private Stream<String> extractListProperty(MutablePropertyValues 
properties, String propertyName) {
+        return Optional.ofNullable(properties.getPropertyValue(propertyName))
+                .map(PropertyValue::getValue)
+                .filter(List.class::isInstance)
+                .map(v -> (List<?>) v)
+                .stream()
+                .flatMap(List::stream)
+                .filter(TypedStringValue.class::isInstance)
+                .map(TypedStringValue.class::cast)
+                .map(TypedStringValue::getValue)
+                .filter(java.util.Objects::nonNull);
+    }
+
     private Class<?> findClass(String className) {
         return findClass(className, Object.class);
     }
diff --git 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringPackageDatabase.java
 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringPackageDatabase.java
index 99918a8552..3c84171faa 100644
--- 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringPackageDatabase.java
+++ 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/HibernateSpringPackageDatabase.java
@@ -61,6 +61,9 @@ public class HibernateSpringPackageDatabase extends 
JpaPersistenceDatabase {
         }
 
         String path = hibernateConnection.getPath();
+        if (path == null) {
+            return false;
+        }
         if (path.contains("/")) {
             return true;
         }
@@ -78,7 +81,11 @@ public class HibernateSpringPackageDatabase extends 
JpaPersistenceDatabase {
         internalPersistenceUnitManager.setResourceLoader(
                 new 
DefaultResourceLoader(Scope.getCurrentScope().getClassLoader()));
 
-        String[] packagesToScan = 
getHibernateConnection().getPath().split(",");
+        String path = getHibernateConnection().getPath();
+        if (path == null) {
+            throw new IllegalStateException("Hibernate connection path is 
null");
+        }
+        String[] packagesToScan = path.split(",");
 
         for (String packageName : packagesToScan) {
             Scope.getCurrentScope().getLog(getClass()).info("Found package " + 
packageName);
diff --git 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/JpaPersistenceDatabase.java
 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/JpaPersistenceDatabase.java
index 66e9ccd81d..3f62528b70 100644
--- 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/JpaPersistenceDatabase.java
+++ 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/JpaPersistenceDatabase.java
@@ -1,6 +1,7 @@
 package liquibase.ext.hibernate.database;
 
 import java.util.Map;
+import java.util.Optional;
 
 import jakarta.persistence.spi.PersistenceUnitInfo;
 
@@ -19,12 +20,14 @@ public class JpaPersistenceDatabase extends 
HibernateEjb3Database {
 
     @Override
     public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) {
-        return conn.getURL().startsWith("jpa:persistence:");
+        return Optional.ofNullable(conn.getURL())
+                .map(url -> url.startsWith("jpa:persistence:"))
+                .orElse(false);
     }
 
     @Override
     public String getDefaultDriver(String url) {
-        if (url.startsWith("jpa:persistence:")) {
+        if (url != null && url.startsWith("jpa:persistence:")) {
             return HibernateDriver.class.getName();
         }
         return null;
@@ -44,12 +47,14 @@ public class JpaPersistenceDatabase extends 
HibernateEjb3Database {
     protected EntityManagerFactoryBuilderImpl 
createEntityManagerFactoryBuilder() {
         DefaultPersistenceUnitManager internalPersistenceUnitManager = new 
DefaultPersistenceUnitManager();
 
-        internalPersistenceUnitManager.setPersistenceXmlLocation(
-                getHibernateConnection().getPath());
-        
internalPersistenceUnitManager.setDefaultPersistenceUnitRootLocation(null);
+        String path = Optional.ofNullable(getHibernateConnection().getPath())
+                .orElseThrow(() -> new IllegalStateException("Hibernate 
connection path is null"));
+
+        internalPersistenceUnitManager.setPersistenceXmlLocation(path);
 
         internalPersistenceUnitManager.preparePersistenceUnitInfos();
-        PersistenceUnitInfo persistenceUnitInfo = 
internalPersistenceUnitManager.obtainDefaultPersistenceUnitInfo();
+        PersistenceUnitInfo persistenceUnitInfo = 
Optional.ofNullable(internalPersistenceUnitManager.obtainDefaultPersistenceUnitInfo())
+                .orElseThrow(() -> new IllegalStateException("No persistence 
unit info found for path: " + path));
 
         return (EntityManagerFactoryBuilderImpl) 
Bootstrap.getEntityManagerFactoryBuilder(
                 persistenceUnitInfo,
diff --git 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/connection/HibernateConnectionMetadata.java
 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/connection/HibernateConnectionMetadata.java
index f6617f7438..969627c9a5 100644
--- 
a/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/connection/HibernateConnectionMetadata.java
+++ 
b/grails-data-hibernate7/dbmigration/src/main/java/liquibase/ext/hibernate/database/connection/HibernateConnectionMetadata.java
@@ -10,61 +10,61 @@ import org.hibernate.Version;
  */
 public class HibernateConnectionMetadata implements DatabaseMetaData {
 
-    private final String url;
+    private String url;
 
     public HibernateConnectionMetadata(String url) {
         this.url = url;
     }
 
-    public boolean allProceduresAreCallable()  {
+    public boolean allProceduresAreCallable() {
         return false;
     }
 
-    public boolean allTablesAreSelectable()  {
+    public boolean allTablesAreSelectable() {
         return false;
     }
 
-    public String getURL()  {
+    public String getURL() {
         return url;
     }
 
-    public String getUserName()  {
+    public String getUserName() {
         return null;
     }
 
-    public boolean isReadOnly()  {
+    public boolean isReadOnly() {
         return true;
     }
 
-    public boolean nullsAreSortedHigh()  {
+    public boolean nullsAreSortedHigh() {
         return false;
     }
 
-    public boolean nullsAreSortedLow()  {
+    public boolean nullsAreSortedLow() {
         return false;
     }
 
-    public boolean nullsAreSortedAtStart()  {
+    public boolean nullsAreSortedAtStart() {
         return false;
     }
 
-    public boolean nullsAreSortedAtEnd()  {
+    public boolean nullsAreSortedAtEnd() {
         return false;
     }
 
-    public String getDatabaseProductName()  {
+    public String getDatabaseProductName() {
         return "Hibernate";
     }
 
-    public String getDatabaseProductVersion()  {
+    public String getDatabaseProductVersion() {
         return Version.getVersionString();
     }
 
-    public String getDriverName()  {
+    public String getDriverName() {
         return null;
     }
 
-    public String getDriverVersion()  {
+    public String getDriverVersion() {
         return "0";
     }
 
@@ -76,479 +76,472 @@ public class HibernateConnectionMetadata implements 
DatabaseMetaData {
         return 0;
     }
 
-    public boolean usesLocalFiles()  {
+    public boolean usesLocalFiles() {
         return false;
     }
 
-    public boolean usesLocalFilePerTable()  {
+    public boolean usesLocalFilePerTable() {
         return false;
     }
 
-    public boolean supportsMixedCaseIdentifiers()  {
+    public boolean supportsMixedCaseIdentifiers() {
         return false;
     }
 
-    public boolean storesUpperCaseIdentifiers()  {
+    public boolean storesUpperCaseIdentifiers() {
         return false;
     }
 
-    public boolean storesLowerCaseIdentifiers()  {
+    public boolean storesLowerCaseIdentifiers() {
         return false;
     }
 
-    public boolean storesMixedCaseIdentifiers()  {
+    public boolean storesMixedCaseIdentifiers() {
         return false;
     }
 
-    public boolean supportsMixedCaseQuotedIdentifiers()  {
+    public boolean supportsMixedCaseQuotedIdentifiers() {
         return false;
     }
 
-    public boolean storesUpperCaseQuotedIdentifiers()  {
+    public boolean storesUpperCaseQuotedIdentifiers() {
         return false;
     }
 
-    public boolean storesLowerCaseQuotedIdentifiers()  {
+    public boolean storesLowerCaseQuotedIdentifiers() {
         return false;
     }
 
-    public boolean storesMixedCaseQuotedIdentifiers()  {
+    public boolean storesMixedCaseQuotedIdentifiers() {
         return false;
     }
 
-    public String getIdentifierQuoteString()  {
+    public String getIdentifierQuoteString() {
         return null;
     }
 
-    public String getSQLKeywords()  {
+    public String getSQLKeywords() {
         return ""; // do not return null here due to 
liquibase.database.jvm.JdbcConnection:30 to avoid NPE's there
     }
 
-    public String getNumericFunctions()  {
+    public String getNumericFunctions() {
         return null;
     }
 
-    public String getStringFunctions()  {
+    public String getStringFunctions() {
         return null;
     }
 
-    public String getSystemFunctions()  {
+    public String getSystemFunctions() {
         return null;
     }
 
-    public String getTimeDateFunctions()  {
+    public String getTimeDateFunctions() {
         return null;
     }
 
-    public String getSearchStringEscape()  {
+    public String getSearchStringEscape() {
         return null;
     }
 
-    public String getExtraNameCharacters()  {
+    public String getExtraNameCharacters() {
         return null;
     }
 
-    public boolean supportsAlterTableWithAddColumn()  {
+    public boolean supportsAlterTableWithAddColumn() {
         return false;
     }
 
-    public boolean supportsAlterTableWithDropColumn()  {
+    public boolean supportsAlterTableWithDropColumn() {
         return false;
     }
 
-    public boolean supportsColumnAliasing()  {
+    public boolean supportsColumnAliasing() {
         return false;
     }
 
-    public boolean nullPlusNonNullIsNull()  {
+    public boolean nullPlusNonNullIsNull() {
         return false;
     }
 
-    public boolean supportsConvert()  {
+    public boolean supportsConvert() {
         return false;
     }
 
-    public boolean supportsConvert(int fromType, int toType)  {
+    public boolean supportsConvert(int fromType, int toType) {
         return false;
     }
 
-    public boolean supportsTableCorrelationNames()  {
+    public boolean supportsTableCorrelationNames() {
         return false;
     }
 
-    public boolean supportsDifferentTableCorrelationNames()  {
+    public boolean supportsDifferentTableCorrelationNames() {
         return false;
     }
 
-    public boolean supportsExpressionsInOrderBy()  {
+    public boolean supportsExpressionsInOrderBy() {
         return false;
     }
 
-    public boolean supportsOrderByUnrelated()  {
+    public boolean supportsOrderByUnrelated() {
         return false;
     }
 
-    public boolean supportsGroupBy()  {
+    public boolean supportsGroupBy() {
         return false;
     }
 
-    public boolean supportsGroupByUnrelated()  {
+    public boolean supportsGroupByUnrelated() {
         return false;
     }
 
-    public boolean supportsGroupByBeyondSelect()  {
+    public boolean supportsGroupByBeyondSelect() {
         return false;
     }
 
-    public boolean supportsLikeEscapeClause()  {
+    public boolean supportsLikeEscapeClause() {
         return false;
     }
 
-    public boolean supportsMultipleResultSets()  {
+    public boolean supportsMultipleResultSets() {
         return false;
     }
 
-    public boolean supportsMultipleTransactions()  {
+    public boolean supportsMultipleTransactions() {
         return false;
     }
 
-    public boolean supportsNonNullableColumns()  {
+    public boolean supportsNonNullableColumns() {
         return false;
     }
 
-    public boolean supportsMinimumSQLGrammar()  {
+    public boolean supportsMinimumSQLGrammar() {
         return false;
     }
 
-    public boolean supportsCoreSQLGrammar()  {
+    public boolean supportsCoreSQLGrammar() {
         return false;
     }
 
-    public boolean supportsExtendedSQLGrammar()  {
+    public boolean supportsExtendedSQLGrammar() {
         return false;
     }
 
-    public boolean supportsANSI92EntryLevelSQL()  {
+    public boolean supportsANSI92EntryLevelSQL() {
         return false;
     }
 
-    public boolean supportsANSI92IntermediateSQL()  {
+    public boolean supportsANSI92IntermediateSQL() {
         return false;
     }
 
-    public boolean supportsANSI92FullSQL()  {
+    public boolean supportsANSI92FullSQL() {
         return false;
     }
 
-    public boolean supportsIntegrityEnhancementFacility()  {
+    public boolean supportsIntegrityEnhancementFacility() {
         return false;
     }
 
-    public boolean supportsOuterJoins()  {
+    public boolean supportsOuterJoins() {
         return false;
     }
 
-    public boolean supportsFullOuterJoins()  {
+    public boolean supportsFullOuterJoins() {
         return false;
     }
 
-    public boolean supportsLimitedOuterJoins()  {
+    public boolean supportsLimitedOuterJoins() {
         return false;
     }
 
-    public String getSchemaTerm()  {
+    public String getSchemaTerm() {
         return null;
     }
 
-    public String getProcedureTerm()  {
+    public String getProcedureTerm() {
         return null;
     }
 
-    public String getCatalogTerm()  {
+    public String getCatalogTerm() {
         return null;
     }
 
-    public boolean isCatalogAtStart()  {
+    public boolean isCatalogAtStart() {
         return false;
     }
 
-    public String getCatalogSeparator()  {
+    public String getCatalogSeparator() {
         return null;
     }
 
-    public boolean supportsSchemasInDataManipulation()  {
+    public boolean supportsSchemasInDataManipulation() {
         return false;
     }
 
-    public boolean supportsSchemasInProcedureCalls()  {
+    public boolean supportsSchemasInProcedureCalls() {
         return false;
     }
 
-    public boolean supportsSchemasInTableDefinitions()  {
+    public boolean supportsSchemasInTableDefinitions() {
         return false;
     }
 
-    public boolean supportsSchemasInIndexDefinitions()  {
+    public boolean supportsSchemasInIndexDefinitions() {
         return false;
     }
 
-    public boolean supportsSchemasInPrivilegeDefinitions()  {
+    public boolean supportsSchemasInPrivilegeDefinitions() {
         return false;
     }
 
-    public boolean supportsCatalogsInDataManipulation()  {
+    public boolean supportsCatalogsInDataManipulation() {
         return false;
     }
 
-    public boolean supportsCatalogsInProcedureCalls()  {
+    public boolean supportsCatalogsInProcedureCalls() {
         return false;
     }
 
-    public boolean supportsCatalogsInTableDefinitions()  {
+    public boolean supportsCatalogsInTableDefinitions() {
         return false;
     }
 
-    public boolean supportsCatalogsInIndexDefinitions()  {
+    public boolean supportsCatalogsInIndexDefinitions() {
         return false;
     }
 
-    public boolean supportsCatalogsInPrivilegeDefinitions()  {
+    public boolean supportsCatalogsInPrivilegeDefinitions() {
         return false;
     }
 
-    public boolean supportsPositionedDelete()  {
+    public boolean supportsPositionedDelete() {
         return false;
     }
 
-    public boolean supportsPositionedUpdate()  {
+    public boolean supportsPositionedUpdate() {
         return false;
     }
 
-    public boolean supportsSelectForUpdate()  {
+    public boolean supportsSelectForUpdate() {
         return false;
     }
 
-    public boolean supportsStoredProcedures()  {
+    public boolean supportsStoredProcedures() {
         return false;
     }
 
-    public boolean supportsSubqueriesInComparisons()  {
+    public boolean supportsSubqueriesInComparisons() {
         return false;
     }
 
-    public boolean supportsSubqueriesInExists()  {
+    public boolean supportsSubqueriesInExists() {
         return false;
     }
 
-    public boolean supportsSubqueriesInIns()  {
+    public boolean supportsSubqueriesInIns() {
         return false;
     }
 
-    public boolean supportsSubqueriesInQuantifieds()  {
+    public boolean supportsSubqueriesInQuantifieds() {
         return false;
     }
 
-    public boolean supportsCorrelatedSubqueries()  {
+    public boolean supportsCorrelatedSubqueries() {
         return false;
     }
 
-    public boolean supportsUnion()  {
+    public boolean supportsUnion() {
         return false;
     }
 
-    public boolean supportsUnionAll()  {
+    public boolean supportsUnionAll() {
         return false;
     }
 
-    public boolean supportsOpenCursorsAcrossCommit()  {
+    public boolean supportsOpenCursorsAcrossCommit() {
         return false;
     }
 
-    public boolean supportsOpenCursorsAcrossRollback()  {
+    public boolean supportsOpenCursorsAcrossRollback() {
         return false;
     }
 
-    public boolean supportsOpenStatementsAcrossCommit()  {
+    public boolean supportsOpenStatementsAcrossCommit() {
         return false;
     }
 
-    public boolean supportsOpenStatementsAcrossRollback()  {
+    public boolean supportsOpenStatementsAcrossRollback() {
         return false;
     }
 
-    public int getMaxBinaryLiteralLength()  {
+    public int getMaxBinaryLiteralLength() {
         return 0;
     }
 
-    public int getMaxCharLiteralLength()  {
+    public int getMaxCharLiteralLength() {
         return 0;
     }
 
-    public int getMaxColumnNameLength()  {
+    public int getMaxColumnNameLength() {
         return 0;
     }
 
-    public int getMaxColumnsInGroupBy()  {
+    public int getMaxColumnsInGroupBy() {
         return 0;
     }
 
-    public int getMaxColumnsInIndex()  {
+    public int getMaxColumnsInIndex() {
         return 0;
     }
 
-    public int getMaxColumnsInOrderBy()  {
+    public int getMaxColumnsInOrderBy() {
         return 0;
     }
 
-    public int getMaxColumnsInSelect()  {
+    public int getMaxColumnsInSelect() {
         return 0;
     }
 
-    public int getMaxColumnsInTable()  {
+    public int getMaxColumnsInTable() {
         return 0;
     }
 
-    public int getMaxConnections()  {
+    public int getMaxConnections() {
         return 0;
     }
 
-    public int getMaxCursorNameLength()  {
+    public int getMaxCursorNameLength() {
         return 0;
     }
 
-    public int getMaxIndexLength()  {
+    public int getMaxIndexLength() {
         return 0;
     }
 
-    public int getMaxSchemaNameLength()  {
+    public int getMaxSchemaNameLength() {
         return 0;
     }
 
-    public int getMaxProcedureNameLength()  {
+    public int getMaxProcedureNameLength() {
         return 0;
     }
 
-    public int getMaxCatalogNameLength()  {
+    public int getMaxCatalogNameLength() {
         return 0;
     }
 
-    public int getMaxRowSize()  {
+    public int getMaxRowSize() {
         return 0;
     }
 
-    public boolean doesMaxRowSizeIncludeBlobs()  {
+    public boolean doesMaxRowSizeIncludeBlobs() {
         return false;
     }
 
-    public int getMaxStatementLength()  {
+    public int getMaxStatementLength() {
         return 0;
     }
 
-    public int getMaxStatements()  {
+    public int getMaxStatements() {
         return 0;
     }
 
-    public int getMaxTableNameLength()  {
+    public int getMaxTableNameLength() {
         return 0;
     }
 
-    public int getMaxTablesInSelect()  {
+    public int getMaxTablesInSelect() {
         return 0;
     }
 
-    public int getMaxUserNameLength()  {
+    public int getMaxUserNameLength() {
         return 0;
     }
 
-    public int getDefaultTransactionIsolation()  {
+    public int getDefaultTransactionIsolation() {
         return 0;
     }
 
-    public boolean supportsTransactions()  {
+    public boolean supportsTransactions() {
         return false;
     }
 
-    public boolean supportsTransactionIsolationLevel(int level)  {
+    public boolean supportsTransactionIsolationLevel(int level) {
         return false;
     }
 
-    public boolean supportsDataDefinitionAndDataManipulationTransactions()  {
+    public boolean supportsDataDefinitionAndDataManipulationTransactions() {
         return false;
     }
 
-    public boolean supportsDataManipulationTransactionsOnly()  {
+    public boolean supportsDataManipulationTransactionsOnly() {
         return false;
     }
 
-    public boolean dataDefinitionCausesTransactionCommit()  {
+    public boolean dataDefinitionCausesTransactionCommit() {
         return false;
     }
 
-    public boolean dataDefinitionIgnoredInTransactions()  {
+    public boolean dataDefinitionIgnoredInTransactions() {
         return false;
     }
 
-    public ResultSet getProcedures(String catalog, String schemaPattern, 
String procedureNamePattern)
-             {
+    public ResultSet getProcedures(String catalog, String schemaPattern, 
String procedureNamePattern) {
         return null;
     }
 
     public ResultSet getProcedureColumns(
-            String catalog, String schemaPattern, String procedureNamePattern, 
String columnNamePattern)
-             {
+            String catalog, String schemaPattern, String procedureNamePattern, 
String columnNamePattern) {
         return null;
     }
 
-    public ResultSet getTables(String catalog, String schemaPattern, String 
tableNamePattern, String[] types)
-             {
+    public ResultSet getTables(String catalog, String schemaPattern, String 
tableNamePattern, String[] types) {
         return null;
     }
 
-    public ResultSet getSchemas()  {
+    public ResultSet getSchemas() {
         return null;
     }
 
-    public ResultSet getCatalogs()  {
+    public ResultSet getCatalogs() {
         return null;
     }
 
-    public ResultSet getTableTypes()  {
+    public ResultSet getTableTypes() {
         return null;
     }
 
-    public ResultSet getColumns(String catalog, String schemaPattern, String 
tableNamePattern, String columnNamePattern)
-             {
+    public ResultSet getColumns(String catalog, String schemaPattern, String 
tableNamePattern, String columnNamePattern) {
         return null;
     }
 
-    public ResultSet getColumnPrivileges(String catalog, String schema, String 
table, String columnNamePattern)
-             {
+    public ResultSet getColumnPrivileges(String catalog, String schema, String 
table, String columnNamePattern) {
         return null;
     }
 
-    public ResultSet getTablePrivileges(String catalog, String schemaPattern, 
String tableNamePattern)
-             {
+    public ResultSet getTablePrivileges(String catalog, String schemaPattern, 
String tableNamePattern) {
         return null;
     }
 
-    public ResultSet getBestRowIdentifier(String catalog, String schema, 
String table, int scope, boolean nullable)
-             {
+    public ResultSet getBestRowIdentifier(String catalog, String schema, 
String table, int scope, boolean nullable) {
         return null;
     }
 
-    public ResultSet getVersionColumns(String catalog, String schema, String 
table)  {
+    public ResultSet getVersionColumns(String catalog, String schema, String 
table) {
         return null;
     }
 
-    public ResultSet getPrimaryKeys(String catalog, String schema, String 
table)  {
+    public ResultSet getPrimaryKeys(String catalog, String schema, String 
table) {
         return null;
     }
 
-    public ResultSet getImportedKeys(String catalog, String schema, String 
table)  {
+    public ResultSet getImportedKeys(String catalog, String schema, String 
table) {
         return null;
     }
 
-    public ResultSet getExportedKeys(String catalog, String schema, String 
table)  {
+    public ResultSet getExportedKeys(String catalog, String schema, String 
table) {
         return null;
     }
 
@@ -558,189 +551,183 @@ public class HibernateConnectionMetadata implements 
DatabaseMetaData {
             String parentTable,
             String foreignCatalog,
             String foreignSchema,
-            String foreignTable)
-             {
+            String foreignTable) {
         return null;
     }
 
-    public ResultSet getTypeInfo()  {
+    public ResultSet getTypeInfo() {
         return null;
     }
 
-    public ResultSet getIndexInfo(String catalog, String schema, String table, 
boolean unique, boolean approximate)
-             {
+    public ResultSet getIndexInfo(String catalog, String schema, String table, 
boolean unique, boolean approximate) {
         return null;
     }
 
-    public boolean supportsResultSetType(int type)  {
+    public boolean supportsResultSetType(int type) {
         return false;
     }
 
-    public boolean supportsResultSetConcurrency(int type, int concurrency)  {
+    public boolean supportsResultSetConcurrency(int type, int concurrency) {
         return false;
     }
 
-    public boolean ownUpdatesAreVisible(int type)  {
+    public boolean ownUpdatesAreVisible(int type) {
         return false;
     }
 
-    public boolean ownDeletesAreVisible(int type)  {
+    public boolean ownDeletesAreVisible(int type) {
         return false;
     }
 
-    public boolean ownInsertsAreVisible(int type)  {
+    public boolean ownInsertsAreVisible(int type) {
         return false;
     }
 
-    public boolean othersUpdatesAreVisible(int type)  {
+    public boolean othersUpdatesAreVisible(int type) {
         return false;
     }
 
-    public boolean othersDeletesAreVisible(int type)  {
+    public boolean othersDeletesAreVisible(int type) {
         return false;
     }
 
-    public boolean othersInsertsAreVisible(int type)  {
+    public boolean othersInsertsAreVisible(int type) {
         return false;
     }
 
-    public boolean updatesAreDetected(int type)  {
+    public boolean updatesAreDetected(int type) {
         return false;
     }
 
-    public boolean deletesAreDetected(int type)  {
+    public boolean deletesAreDetected(int type) {
         return false;
     }
 
-    public boolean insertsAreDetected(int type)  {
+    public boolean insertsAreDetected(int type) {
         return false;
     }
 
-    public boolean supportsBatchUpdates()  {
+    public boolean supportsBatchUpdates() {
         return false;
     }
 
-    public ResultSet getUDTs(String catalog, String schemaPattern, String 
typeNamePattern, int[] types)
-             {
+    public ResultSet getUDTs(String catalog, String schemaPattern, String 
typeNamePattern, int[] types) {
         return null;
     }
 
-    public Connection getConnection()  {
+    public Connection getConnection() {
         return null;
     }
 
-    public boolean supportsSavepoints()  {
+    public boolean supportsSavepoints() {
         return false;
     }
 
-    public boolean supportsNamedParameters()  {
+    public boolean supportsNamedParameters() {
         return false;
     }
 
-    public boolean supportsMultipleOpenResults()  {
+    public boolean supportsMultipleOpenResults() {
         return false;
     }
 
-    public boolean supportsGetGeneratedKeys()  {
+    public boolean supportsGetGeneratedKeys() {
         return false;
     }
 
-    public ResultSet getSuperTypes(String catalog, String schemaPattern, 
String typeNamePattern)  {
+    public ResultSet getSuperTypes(String catalog, String schemaPattern, 
String typeNamePattern) {
         return null;
     }
 
-    public ResultSet getSuperTables(String catalog, String schemaPattern, 
String tableNamePattern)  {
+    public ResultSet getSuperTables(String catalog, String schemaPattern, 
String tableNamePattern) {
         return null;
     }
 
     public ResultSet getAttributes(
-            String catalog, String schemaPattern, String typeNamePattern, 
String attributeNamePattern)
-             {
+            String catalog, String schemaPattern, String typeNamePattern, 
String attributeNamePattern) {
         return null;
     }
 
-    public boolean supportsResultSetHoldability(int holdability)  {
+    public boolean supportsResultSetHoldability(int holdability) {
         return false;
     }
 
-    public int getResultSetHoldability()  {
+    public int getResultSetHoldability() {
         return 0;
     }
 
-    public int getDatabaseMajorVersion()  {
+    public int getDatabaseMajorVersion() {
         return 0;
     }
 
-    public int getDatabaseMinorVersion()  {
+    public int getDatabaseMinorVersion() {
         return 0;
     }
 
-    public int getJDBCMajorVersion()  {
+    public int getJDBCMajorVersion() {
         return 0;
     }
 
-    public int getJDBCMinorVersion()  {
+    public int getJDBCMinorVersion() {
         return 0;
     }
 
-    public int getSQLStateType()  {
-        return 0;
+    public int getSQLStateType() {
+        return DatabaseMetaData.sqlStateSQL;
     }
 
-    public boolean locatorsUpdateCopy()  {
+    public boolean locatorsUpdateCopy() {
         return false;
     }
 
-    public boolean supportsStatementPooling()  {
+    public boolean supportsStatementPooling() {
         return false;
     }
 
-    public RowIdLifetime getRowIdLifetime()  {
+    public RowIdLifetime getRowIdLifetime() {
         return null;
     }
 
-    public ResultSet getSchemas(String catalog, String schemaPattern)  {
+    public ResultSet getSchemas(String catalog, String schemaPattern) {
         return null;
     }
 
-    public boolean supportsStoredFunctionsUsingCallSyntax()  {
+    public boolean supportsStoredFunctionsUsingCallSyntax() {
         return false;
     }
 
-    public boolean autoCommitFailureClosesAllResultSets()  {
+    public boolean autoCommitFailureClosesAllResultSets() {
         return false;
     }
 
-    public ResultSet getClientInfoProperties()  {
+    public ResultSet getClientInfoProperties() {
         return null;
     }
 
-    public ResultSet getFunctions(String catalog, String schemaPattern, String 
functionNamePattern)
-             {
+    public ResultSet getFunctions(String catalog, String schemaPattern, String 
functionNamePattern) {
         return null;
     }
 
     public ResultSet getFunctionColumns(
-            String catalog, String schemaPattern, String functionNamePattern, 
String columnNamePattern)
-             {
+            String catalog, String schemaPattern, String functionNamePattern, 
String columnNamePattern) {
         return null;
     }
 
-    public <T> T unwrap(Class<T> iface)  {
+    public <T> T unwrap(Class<T> iface) {
         return null;
     }
 
-    public boolean isWrapperFor(Class<?> iface)  {
+    public boolean isWrapperFor(Class<?> iface) {
         return false;
     }
 
     // @Override only override for java 1.7
-    public boolean generatedKeyAlwaysReturned()  {
+    public boolean generatedKeyAlwaysReturned() {
         return false;
     }
 
     // @Override only override for java 1.7
-    public ResultSet getPseudoColumns(String arg0, String arg1, String arg2, 
String arg3)  {
+    public ResultSet getPseudoColumns(String arg0, String arg1, String arg2, 
String arg3) {
         return null;
     }
 }
diff --git 
a/grails-data-hibernate7/dbmigration/src/test/java/liquibase/ext/hibernate/database/HibernateSpringDatabaseTest.java
 
b/grails-data-hibernate7/dbmigration/src/test/java/liquibase/ext/hibernate/database/HibernateSpringDatabaseTest.java
index 1d9fee8426..c844dca600 100644
--- 
a/grails-data-hibernate7/dbmigration/src/test/java/liquibase/ext/hibernate/database/HibernateSpringDatabaseTest.java
+++ 
b/grails-data-hibernate7/dbmigration/src/test/java/liquibase/ext/hibernate/database/HibernateSpringDatabaseTest.java
@@ -36,15 +36,36 @@ public class HibernateSpringDatabaseTest {
         }
     }
 
+    @Test
+    public void testIsCorrectDatabaseImplementation() {
+        HibernateSpringBeanDatabase database = new 
HibernateSpringBeanDatabase();
+        assertTrue(database.isCorrectDatabaseImplementation(new 
JdbcConnection(new 
HibernateConnection("hibernate:spring:spring.ctx.xml?bean=sessionFactory", new 
ClassLoaderResourceAccessor()))));
+        assertFalse(database.isCorrectDatabaseImplementation(new 
JdbcConnection(new HibernateConnection("hibernate:classic:hibernate.cfg.xml", 
new ClassLoaderResourceAccessor()))));
+    }
+
     @Test
     public void testSpringUrlSimple() throws DatabaseException {
-        conn = new JdbcConnection(new 
HibernateConnection("hibernate:spring:spring.ctx.xml?bean=sessionFactory", new 
ClassLoaderResourceAccessor()));
+        conn = new JdbcConnection(new 
HibernateConnection("hibernate:spring:spring.ctx.xml?bean=sessionFactory&hibernate.dialect=org.hibernate.dialect.H2Dialect",
 new ClassLoaderResourceAccessor()));
         db = new HibernateSpringBeanDatabase();
         db.setConnection(conn);
         
assertNotNull(db.getMetadata().getEntityBinding(AuctionItem.class.getName()));
         
assertNotNull(db.getMetadata().getEntityBinding(Watcher.class.getName()));
+        assertEquals("org.hibernate.dialect.H2Dialect", 
db.getProperty("hibernate.dialect"));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testSpringUrlNoBean() throws DatabaseException {
+        conn = new JdbcConnection(new 
HibernateConnection("hibernate:spring:spring.ctx.xml", new 
ClassLoaderResourceAccessor()));
+        db = new HibernateSpringBeanDatabase();
+        db.setConnection(conn);
     }
 
+    @Test(expected = IllegalStateException.class)
+    public void testSpringUrlMissingBean() throws DatabaseException {
+        conn = new JdbcConnection(new 
HibernateConnection("hibernate:spring:spring.ctx.xml?bean=missingBean", new 
ClassLoaderResourceAccessor()));
+        db = new HibernateSpringBeanDatabase();
+        db.setConnection(conn);
+    }
 
     @Test
     public void testSpringPackageScanningMustHaveItemClassMapping() throws 
DatabaseException {

Reply via email to