mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-19 16:16:19 +00:00
chore[orm]: comment
This commit is contained in:
1 parent
82b8e6211b
commit
facea30fb5
2 files changed
+9
-7
No files matched your search
@@ -242,6 +242,8 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 游戏中80%都是执行更新的操作,这样做会极大的提高更新速度
|
// 游戏中80%都是执行更新的操作,这样做会极大的提高更新速度
|
||||||
|
// 没有并发问题的entity指的是内部没有使用集合或者使用的集合全部支持并发操作
|
||||||
|
// 没有并发问题的entity还是在异步线程池Event慢慢更新,有并发问题的entity才放到原来的update线程去更新(第一次update会记录entity所在线程)
|
||||||
@Override
|
@Override
|
||||||
public void persistAll() {
|
public void persistAll() {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ public class OrmManager implements IOrmManager {
|
|||||||
var types = ((ParameterizedType) type).getActualTypeArguments();
|
var types = ((ParameterizedType) type).getActualTypeArguments();
|
||||||
// 必须声明Set的泛型类
|
// 必须声明Set的泛型类
|
||||||
AssertionUtils.isTrue(types.length == 1, "Set type declaration in [class:{}] is incorrect, and the generic class must be declared in [field:{}]", clazz.getCanonicalName(), field.getName());
|
AssertionUtils.isTrue(types.length == 1, "Set type declaration in [class:{}] is incorrect, and the generic class must be declared in [field:{}]", clazz.getCanonicalName(), field.getName());
|
||||||
checkSubEntity(clazz, types[0]);
|
hasUnsafeCollectionInner(clazz, types[0]);
|
||||||
} else if (List.class.isAssignableFrom(fieldType)) {
|
} else if (List.class.isAssignableFrom(fieldType)) {
|
||||||
// 是一个List
|
// 是一个List
|
||||||
hasUnsafeCollection |= unsafeCollections.contains(fieldType);
|
hasUnsafeCollection |= unsafeCollections.contains(fieldType);
|
||||||
@@ -523,7 +523,7 @@ public class OrmManager implements IOrmManager {
|
|||||||
var types = ((ParameterizedType) type).getActualTypeArguments();
|
var types = ((ParameterizedType) type).getActualTypeArguments();
|
||||||
AssertionUtils.isTrue(types.length == 1, "List type declaration in [class:{}] is incorrect, and the generic class must be declared in [field:{}]", clazz.getCanonicalName(), field.getName());
|
AssertionUtils.isTrue(types.length == 1, "List type declaration in [class:{}] is incorrect, and the generic class must be declared in [field:{}]", clazz.getCanonicalName(), field.getName());
|
||||||
|
|
||||||
checkSubEntity(clazz, types[0]);
|
hasUnsafeCollectionInner(clazz, types[0]);
|
||||||
} else if (Map.class.isAssignableFrom(fieldType)) {
|
} else if (Map.class.isAssignableFrom(fieldType)) {
|
||||||
// 是Map接口类型
|
// 是Map接口类型
|
||||||
hasUnsafeCollection |= unsafeCollections.contains(fieldType);
|
hasUnsafeCollection |= unsafeCollections.contains(fieldType);
|
||||||
@@ -546,7 +546,7 @@ public class OrmManager implements IOrmManager {
|
|||||||
if (!ClassUtils.isBaseType((Class<?>) keyType)) {
|
if (!ClassUtils.isBaseType((Class<?>) keyType)) {
|
||||||
throw new RunException("[class:{}] type declaration is incorrect, and the key type of the Map must be the Base type", clazz.getCanonicalName());
|
throw new RunException("[class:{}] type declaration is incorrect, and the key type of the Map must be the Base type", clazz.getCanonicalName());
|
||||||
}
|
}
|
||||||
hasUnsafeCollection |= checkSubEntity(clazz, valueType);
|
hasUnsafeCollection |= hasUnsafeCollectionInner(clazz, valueType);
|
||||||
} else if (ObjectId.class.isAssignableFrom(fieldType)) {
|
} else if (ObjectId.class.isAssignableFrom(fieldType)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
@@ -558,16 +558,16 @@ public class OrmManager implements IOrmManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean checkSubEntity(Class<?> currentEntityClass, Type type) {
|
private boolean hasUnsafeCollectionInner(Class<?> currentEntityClass, Type type) {
|
||||||
if (type instanceof ParameterizedType) {
|
if (type instanceof ParameterizedType) {
|
||||||
// 泛型类
|
// 泛型类
|
||||||
Class<?> clazz = (Class<?>) ((ParameterizedType) type).getRawType();
|
Class<?> clazz = (Class<?>) ((ParameterizedType) type).getRawType();
|
||||||
if (Set.class.isAssignableFrom(clazz)) {
|
if (Set.class.isAssignableFrom(clazz)) {
|
||||||
// Set<Set<String>>
|
// Set<Set<String>>
|
||||||
return unsafeCollections.contains(clazz) | checkSubEntity(currentEntityClass, ((ParameterizedType) type).getActualTypeArguments()[0]);
|
return unsafeCollections.contains(clazz) | hasUnsafeCollectionInner(currentEntityClass, ((ParameterizedType) type).getActualTypeArguments()[0]);
|
||||||
} else if (List.class.isAssignableFrom(clazz)) {
|
} else if (List.class.isAssignableFrom(clazz)) {
|
||||||
// List<List<String>>
|
// List<List<String>>
|
||||||
return unsafeCollections.contains(clazz) | checkSubEntity(currentEntityClass, ((ParameterizedType) type).getActualTypeArguments()[0]);
|
return unsafeCollections.contains(clazz) | hasUnsafeCollectionInner(currentEntityClass, ((ParameterizedType) type).getActualTypeArguments()[0]);
|
||||||
} else if (Map.class.isAssignableFrom(clazz)) {
|
} else if (Map.class.isAssignableFrom(clazz)) {
|
||||||
// Map<List<String>, List<String>>
|
// Map<List<String>, List<String>>
|
||||||
var types = ((ParameterizedType) type).getActualTypeArguments();
|
var types = ((ParameterizedType) type).getActualTypeArguments();
|
||||||
@@ -576,7 +576,7 @@ public class OrmManager implements IOrmManager {
|
|||||||
if (!ClassUtils.isBaseType((Class<?>) keyType)) {
|
if (!ClassUtils.isBaseType((Class<?>) keyType)) {
|
||||||
throw new RunException("The key of the map in the ORM must be of the Base type");
|
throw new RunException("The key of the map in the ORM must be of the Base type");
|
||||||
}
|
}
|
||||||
return unsafeCollections.contains(clazz) | checkSubEntity(currentEntityClass, valueType);
|
return unsafeCollections.contains(clazz) | hasUnsafeCollectionInner(currentEntityClass, valueType);
|
||||||
}
|
}
|
||||||
} else if (type instanceof Class) {
|
} else if (type instanceof Class) {
|
||||||
Class<?> clazz = ((Class<?>) type);
|
Class<?> clazz = ((Class<?>) type);
|
||||||
|
|||||||
Reference in new issue
Block a user