diff --git a/src/META-INF/persistence-template.xml b/src/META-INF/persistence-template.xml
index c674c631c..35236afa2 100644
--- a/src/META-INF/persistence-template.xml
+++ b/src/META-INF/persistence-template.xml
@@ -28,7 +28,7 @@
-
+
diff --git a/src/org/redkale/source/DataDefaultSource.java b/src/org/redkale/source/DataDefaultSource.java
index 7afdb261b..bcf41c939 100644
--- a/src/org/redkale/source/DataDefaultSource.java
+++ b/src/org/redkale/source/DataDefaultSource.java
@@ -36,7 +36,7 @@ public final class DataDefaultSource implements DataSource, Function 0 && info.tablenotexistSqlstates.contains(';' + se.getSQLState() + ';')) {
+ Statement st = conn.createStatement();
+ st.execute("CREATE DATABASE " + newTable.substring(0, newTable.indexOf('.')));
+ st.close();
+ try {
+ st = conn.createStatement();
+ st.execute(info.tablecopySQL.replace("${newtable}", newTable).replace("${oldtable}", oldTable));
+ st.close();
+ info.tables.add(newTable);
+ } catch (SQLException sqle2) {
+ logger.log(Level.SEVERE, "create table(" + info.tablecopySQL.replace("${newtable}", newTable).replace("${oldtable}", oldTable) + ") error", sqle2);
+ }
+ } else {
+ logger.log(Level.SEVERE, "create table(" + info.tablecopySQL.replace("${newtable}", newTable).replace("${oldtable}", oldTable) + ") error", sqle);
+ }
}
}
}
diff --git a/src/org/redkale/source/EntityInfo.java b/src/org/redkale/source/EntityInfo.java
index 0acfa2508..c9b9d4986 100644
--- a/src/org/redkale/source/EntityInfo.java
+++ b/src/org/redkale/source/EntityInfo.java
@@ -62,7 +62,7 @@ public final class EntityInfo {
final String notcontainSQL; //用于反向LIKE使用
- final String tablenotexistSqlstate; //用于判断表不存在的使用
+ final String tablenotexistSqlstates; //用于判断表不存在的使用, 多个SQLState用;隔开
final String tablecopySQL; //用于复制表结构使用
@@ -277,7 +277,7 @@ public final class EntityInfo {
this.containSQL = conf.getProperty(JDBC_CONTAIN_SQLTEMPLATE, "LOCATE(${keystr}, ${column}) > 0");
this.notcontainSQL = conf.getProperty(JDBC_NOTCONTAIN_SQLTEMPLATE, "LOCATE(${keystr}, ${column}) = 0");
- this.tablenotexistSqlstate = conf.getProperty(JDBC_TABLENOTEXIST_SQLSTATE, "42S02");
+ this.tablenotexistSqlstates = ";" + conf.getProperty(JDBC_TABLENOTEXIST_SQLSTATES, "42000;42S02") + ";";
this.tablecopySQL = conf.getProperty(JDBC_TABLECOPY_SQLTEMPLATE, "CREATE TABLE ${newtable} LIKE ${oldtable}");
}