mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-07 06:30:17 +00:00
test[orm]: entity cache test
This commit is contained in:
@@ -23,6 +23,8 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* @author godotg
|
||||
@@ -35,6 +37,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);
|
||||
@@ -62,4 +71,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user