diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 30dff45c50..8b399b3cc5 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -425,7 +425,15 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException { } } } - + + if (this.databaseIdProvider != null) {//fix #64 set databaseId before parse mapper xmls + try { + configuration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource)); + } catch (SQLException e) { + throw new NestedIOException("Failed getting a databaseId", e); + } + } + if (xmlConfigBuilder != null) { try { xmlConfigBuilder.parse(); @@ -446,14 +454,6 @@ protected SqlSessionFactory buildSqlSessionFactory() throws IOException { configuration.setEnvironment(new Environment(this.environment, this.transactionFactory, this.dataSource)); - if (this.databaseIdProvider != null) { - try { - configuration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource)); - } catch (SQLException e) { - throw new NestedIOException("Failed getting a databaseId", e); - } - } - if (!isEmpty(this.mapperLocations)) { for (Resource mapperLocation : this.mapperLocations) { if (mapperLocation == null) {