This commit is contained in:
@@ -18,24 +18,6 @@ import javax.annotation.Resource;
|
|||||||
import javax.sql.ConnectionPoolDataSource;
|
import javax.sql.ConnectionPoolDataSource;
|
||||||
import javax.xml.stream.*;
|
import javax.xml.stream.*;
|
||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
import static org.redkale.source.FilterNode.formatToString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -419,7 +401,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
if (distributed) info.createPrimaryValue(value);
|
if (distributed) info.createPrimaryValue(value);
|
||||||
for (Attribute<T, Serializable> attr : attrs) {
|
for (Attribute<T, Serializable> attr : attrs) {
|
||||||
Object a = attr.get(value);
|
Object a = attr.get(value);
|
||||||
ps[i] = formatToString(a);
|
ps[i] = FilterNode.formatToString(a);
|
||||||
prestmt.setObject(++i, a);
|
prestmt.setObject(++i, a);
|
||||||
}
|
}
|
||||||
prestmt.addBatch();
|
prestmt.addBatch();
|
||||||
@@ -466,7 +448,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
if (obj != null && obj.getClass().isArray()) {
|
if (obj != null && obj.getClass().isArray()) {
|
||||||
sb.append("'[length=").append(java.lang.reflect.Array.getLength(obj)).append("]'");
|
sb.append("'[length=").append(java.lang.reflect.Array.getLength(obj)).append("]'");
|
||||||
} else {
|
} else {
|
||||||
sb.append(formatToString(obj));
|
sb.append(FilterNode.formatToString(obj));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sb.append(ch);
|
sb.append(ch);
|
||||||
@@ -563,7 +545,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
if (keys.length == 0) return;
|
if (keys.length == 0) return;
|
||||||
try {
|
try {
|
||||||
if (!info.isVirtualEntity()) {
|
if (!info.isVirtualEntity()) {
|
||||||
String sql = "DELETE FROM " + info.getTable() + " WHERE " + info.getPrimarySQLColumn() + " IN " + formatToString(keys);
|
String sql = "DELETE FROM " + info.getTable() + " WHERE " + info.getPrimarySQLColumn() + " IN " + FilterNode.formatToString(keys);
|
||||||
if (debug.get()) logger.finest(info.getType().getSimpleName() + " delete sql=" + sql);
|
if (debug.get()) logger.finest(info.getType().getSimpleName() + " delete sql=" + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -692,7 +674,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (Attribute<T, Serializable> attr : attrs) {
|
for (Attribute<T, Serializable> attr : attrs) {
|
||||||
Object a = attr.get(value);
|
Object a = attr.get(value);
|
||||||
ps[i] = formatToString(a);
|
ps[i] = FilterNode.formatToString(a);
|
||||||
prestmt.setObject(++i, a);
|
prestmt.setObject(++i, a);
|
||||||
}
|
}
|
||||||
prestmt.setObject(++i, primary.get(value));
|
prestmt.setObject(++i, primary.get(value));
|
||||||
@@ -760,7 +742,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
try {
|
try {
|
||||||
if (!info.isVirtualEntity()) {
|
if (!info.isVirtualEntity()) {
|
||||||
String sql = "UPDATE " + info.getTable() + " SET " + info.getSQLColumn(null, column) + " = "
|
String sql = "UPDATE " + info.getTable() + " SET " + info.getSQLColumn(null, column) + " = "
|
||||||
+ formatToString(value) + " WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(id);
|
+ FilterNode.formatToString(value) + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(id);
|
||||||
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -817,7 +799,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
CharSequence where = node.createSQLExpress(info, joinTabalis);
|
CharSequence where = node.createSQLExpress(info, joinTabalis);
|
||||||
|
|
||||||
String sql = "UPDATE " + info.getTable() + " a SET " + info.getSQLColumn("a", column) + " = "
|
String sql = "UPDATE " + info.getTable() + " a SET " + info.getSQLColumn("a", column) + " = "
|
||||||
+ formatToString(value) + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where));
|
+ FilterNode.formatToString(value) + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where));
|
||||||
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -872,7 +854,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
if (!info.isVirtualEntity()) {
|
if (!info.isVirtualEntity()) {
|
||||||
String col = info.getSQLColumn(null, column);
|
String col = info.getSQLColumn(null, column);
|
||||||
String sql = "UPDATE " + info.getTable() + " SET " + col + " = " + col + " + (" + incvalue
|
String sql = "UPDATE " + info.getTable() + " SET " + col + " = " + col + " + (" + incvalue
|
||||||
+ ") WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(id);
|
+ ") WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(id);
|
||||||
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -928,7 +910,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
if (!info.isVirtualEntity()) {
|
if (!info.isVirtualEntity()) {
|
||||||
String col = info.getSQLColumn(null, column);
|
String col = info.getSQLColumn(null, column);
|
||||||
String sql = "UPDATE " + info.getTable() + " SET " + col + " = " + col + " & (" + andvalue
|
String sql = "UPDATE " + info.getTable() + " SET " + col + " = " + col + " & (" + andvalue
|
||||||
+ ") WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(id);
|
+ ") WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(id);
|
||||||
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -984,7 +966,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
if (!info.isVirtualEntity()) {
|
if (!info.isVirtualEntity()) {
|
||||||
String col = info.getSQLColumn(null, column);
|
String col = info.getSQLColumn(null, column);
|
||||||
String sql = "UPDATE " + info.getTable() + " SET " + col + " = " + col + " | (" + orvalue
|
String sql = "UPDATE " + info.getTable() + " SET " + col + " = " + col + " | (" + orvalue
|
||||||
+ ") WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(id);
|
+ ") WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(id);
|
||||||
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
if (debug.get()) logger.finest(info.getType().getSimpleName() + " update sql=" + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -1046,11 +1028,11 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
attrs.add(attr);
|
attrs.add(attr);
|
||||||
if (!virtual) {
|
if (!virtual) {
|
||||||
if (setsql.length() > 0) setsql.append(", ");
|
if (setsql.length() > 0) setsql.append(", ");
|
||||||
setsql.append(info.getSQLColumn(null, col)).append(" = ").append(formatToString(attr.get(bean)));
|
setsql.append(info.getSQLColumn(null, col)).append(" = ").append(FilterNode.formatToString(attr.get(bean)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!virtual) {
|
if (!virtual) {
|
||||||
String sql = "UPDATE " + info.getTable() + " SET " + setsql + " WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(id);
|
String sql = "UPDATE " + info.getTable() + " SET " + setsql + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(id);
|
||||||
if (debug.get()) logger.finest(bean.getClass().getSimpleName() + ": " + sql);
|
if (debug.get()) logger.finest(bean.getClass().getSimpleName() + ": " + sql);
|
||||||
final Statement stmt = conn.createStatement();
|
final Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
@@ -1110,7 +1092,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
attrs.add(attr);
|
attrs.add(attr);
|
||||||
if (!virtual) {
|
if (!virtual) {
|
||||||
if (setsql.length() > 0) setsql.append(", ");
|
if (setsql.length() > 0) setsql.append(", ");
|
||||||
setsql.append(info.getSQLColumn("a", col)).append(" = ").append(formatToString(attr.get(bean)));
|
setsql.append(info.getSQLColumn("a", col)).append(" = ").append(FilterNode.formatToString(attr.get(bean)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!virtual) {
|
if (!virtual) {
|
||||||
@@ -1316,7 +1298,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
final Connection conn = createReadSQLConnection();
|
final Connection conn = createReadSQLConnection();
|
||||||
try {
|
try {
|
||||||
final SelectColumn sels = selects;
|
final SelectColumn sels = selects;
|
||||||
final String sql = "SELECT * FROM " + info.getTable() + " WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(pk);
|
final String sql = "SELECT * FROM " + info.getTable() + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(pk);
|
||||||
if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(clazz.getSimpleName() + " find sql=" + sql);
|
if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(clazz.getSimpleName() + " find sql=" + sql);
|
||||||
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
final ResultSet set = ps.executeQuery();
|
final ResultSet set = ps.executeQuery();
|
||||||
@@ -1427,7 +1409,7 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
|||||||
|
|
||||||
final Connection conn = createReadSQLConnection();
|
final Connection conn = createReadSQLConnection();
|
||||||
try {
|
try {
|
||||||
final String sql = "SELECT COUNT(*) FROM " + info.getTable() + " WHERE " + info.getPrimarySQLColumn() + " = " + formatToString(pk);
|
final String sql = "SELECT COUNT(*) FROM " + info.getTable() + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(pk);
|
||||||
if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(clazz.getSimpleName() + " exists sql=" + sql);
|
if (debug.get() && info.isLoggable(Level.FINEST)) logger.finest(clazz.getSimpleName() + " exists sql=" + sql);
|
||||||
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
final ResultSet set = ps.executeQuery();
|
final ResultSet set = ps.executeQuery();
|
||||||
|
|||||||
Reference in New Issue
Block a user