This commit is contained in:
Redkale
2016-07-08 21:41:15 +08:00
parent a996ab5eb5
commit 73a7864e09
3 changed files with 17 additions and 176 deletions

View File

@@ -19,69 +19,6 @@ import javax.sql.ConnectionPoolDataSource;
import javax.xml.stream.*;
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;
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;
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;
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;
/**
*

View File

@@ -474,121 +474,19 @@ public final class EntityCache<T> {
final Attribute<T, Serializable> pattr = getAttribute(sub[0].substring(pos + 1, pos2));
final String func = sub[0].substring(0, pos);
if ("ABS".equalsIgnoreCase(func)) {
Function getter = null;
if (pattr.type() == int.class || pattr.type() == Integer.class) {
attr = new Attribute<T, Serializable>() {
@Override
public Class type() {
return pattr.type();
}
@Override
public Class declaringClass() {
return pattr.declaringClass();
}
@Override
public String field() {
return pattr.field();
}
@Override
public Serializable get(T obj) {
return Math.abs(((Number) pattr.get(obj)).intValue());
}
@Override
public void set(T obj, Serializable value) {
pattr.set(obj, value);
}
};
getter = x -> Math.abs(((Number) pattr.get((T) x)).intValue());
} else if (pattr.type() == long.class || pattr.type() == Long.class) {
attr = new Attribute<T, Serializable>() {
@Override
public Class type() {
return pattr.type();
}
@Override
public Class declaringClass() {
return pattr.declaringClass();
}
@Override
public String field() {
return pattr.field();
}
@Override
public Serializable get(T obj) {
return Math.abs(((Number) pattr.get(obj)).longValue());
}
@Override
public void set(T obj, Serializable value) {
pattr.set(obj, value);
}
};
getter = x -> Math.abs(((Number) pattr.get((T) x)).longValue());
} else if (pattr.type() == float.class || pattr.type() == Float.class) {
attr = new Attribute<T, Serializable>() {
@Override
public Class type() {
return pattr.type();
}
@Override
public Class declaringClass() {
return pattr.declaringClass();
}
@Override
public String field() {
return pattr.field();
}
@Override
public Serializable get(T obj) {
return Math.abs(((Number) pattr.get(obj)).floatValue());
}
@Override
public void set(T obj, Serializable value) {
pattr.set(obj, value);
}
};
getter = x -> Math.abs(((Number) pattr.get((T) x)).floatValue());
} else if (pattr.type() == double.class || pattr.type() == Double.class) {
attr = new Attribute<T, Serializable>() {
@Override
public Class type() {
return pattr.type();
}
@Override
public Class declaringClass() {
return pattr.declaringClass();
}
@Override
public String field() {
return pattr.field();
}
@Override
public Serializable get(T obj) {
return Math.abs(((Number) pattr.get(obj)).doubleValue());
}
@Override
public void set(T obj, Serializable value) {
pattr.set(obj, value);
}
};
getter = x -> Math.abs(((Number) pattr.get((T) x)).doubleValue());
} else {
throw new RuntimeException("Flipper not supported sort illegal type by ABS (" + flipper.getSort() + ")");
}
attr = (Attribute<T, Serializable>) Attribute.create(pattr.declaringClass(), pattr.field(), pattr.type(), getter, (o, v) -> pattr.set(o, v));
} else if (func.isEmpty()) {
attr = pattr;
} else {

View File

@@ -99,7 +99,7 @@ public final class EntityInfo<T> {
//------------------------------------------------------------
public static <T> EntityInfo<T> load(Class<T> clazz, final int nodeid, final boolean cacheForbidden, final Properties conf,
Function<Class, List> fullloader) {
Function<Class, List> fullloader) {
EntityInfo rs = entityInfos.get(clazz);
if (rs != null) return rs;
synchronized (entityInfos) {
@@ -312,7 +312,7 @@ public final class EntityInfo<T> {
}
protected String createSQLOrderby(Flipper flipper) {
if (flipper == null || flipper.getSort() == null || flipper.getSort().isEmpty() || flipper.getSort().indexOf(';') >= 0 || flipper.getSort().indexOf('\n') >= 0 ) return "";
if (flipper == null || flipper.getSort() == null || flipper.getSort().isEmpty() || flipper.getSort().indexOf(';') >= 0 || flipper.getSort().indexOf('\n') >= 0) return "";
final String sort = flipper.getSort();
String sql = this.sortOrderbySqls.get(sort);
if (sql != null) return sql;
@@ -369,12 +369,18 @@ public final class EntityInfo<T> {
Serializable o = (Serializable) set.getObject(this.getSQLColumn(null, attr.field()));
if (o != null) {
Class t = attr.type();
if (t == short.class) {
if (t == int.class) {
o = ((Number) o).intValue();
} else if (t == short.class) {
o = ((Number) o).shortValue();
} else if (t == long.class) {
o = ((Number) o).longValue();
} else if (t == int.class) {
o = ((Number) o).intValue();
} else if (t == float.class) {
o = ((Number) o).floatValue();
} else if (t == double.class) {
o = ((Number) o).doubleValue();
} else if (t == byte.class) {
o = ((Number) o).byteValue();
}
}
attr.set(obj, o);