Merge remote-tracking branch 'origin/main'

This commit is contained in:
awake
2024-05-23 17:06:17 +08:00
@@ -24,6 +24,8 @@ import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.ArrayList;
/**
* @author godotg
@@ -36,6 +38,13 @@ public class EntityCachesTest {
public void test() {
var context = new ClassPathXmlApplicationContext("application.xml");
// 每次运行前先删除数据库
var collection = OrmContext.getOrmManager().getCollection(UserEntity.class);
collection.drop();
// 再插入
batchInsert();
// 动态去拿到UserEntity的EntityCaches
@SuppressWarnings("unchecked")
var userEntityCaches = (IEntityCache<Long, UserEntity>) OrmContext.getOrmManager().getEntityCaches(UserEntity.class);
@@ -81,4 +90,13 @@ public class EntityCachesTest {
ThreadUtils.sleep(Long.MAX_VALUE);
}
public void batchInsert() {
var listUser = new ArrayList<UserEntity>();
for (var i = 1; i <= 10; i++) {
var userEntity = new UserEntity(i, (byte) 1, (short) i, i, true, "helloOrm" + i, "helloOrm" + i);
listUser.add(userEntity);
}
OrmContext.getAccessor().batchInsert(listUser);
}
}