This commit is contained in:
kamhung
2015-11-25 17:24:19 +08:00
parent 051016f423
commit 9f3d2ff874
2 changed files with 12 additions and 5 deletions

View File

@@ -1029,8 +1029,8 @@ public final class DataDefaultSource implements DataSource, Nameable {
//---------------------------------------------------
final EntityCache<T> cache = info.getCache();
if (cache == null) return;
cache.update(value, attrs);
if (cacheListener != null) cacheListener.updateCache(clazz, value);
T rs = cache.update(value, attrs);
if (cacheListener != null) cacheListener.updateCache(clazz, rs);
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -404,13 +404,14 @@ public final class EntityCache<T> {
this.reproduce.copy(rs, value);
}
public void update(final T value, Collection<Attribute<T, Serializable>> attrs) {
if (value == null) return;
public T update(final T value, Collection<Attribute<T, Serializable>> attrs) {
if (value == null) return value;
T rs = this.map.get(this.primary.get(value));
if (rs == null) return;
if (rs == null) return rs;
for (Attribute attr : attrs) {
attr.set(rs, attr.get(value));
}
return rs;
}
public <V> T update(final Serializable id, Attribute<T, V> attr, final V fieldValue) {
@@ -672,6 +673,12 @@ public final class EntityCache<T> {
@Override
public boolean test(FilterNode node) {
if (node == null || node.isOr()) return false;
if (!attribute.field().equals(node.column)) return false;
if (node.nodes == null) return true;
for (FilterNode n : node.nodes) {
if (!test(n)) return false;
}
return true;
}
};