use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetDemoTest method testEntityNetQuery.
@Test
public void testEntityNetQuery() {
insertDemoData();
EntityNet net = ctx.nQuery(new EntityNetHandler(User.class, Email.class), "select u.**, e.** from usertb u, emailtb e where u.id=e.userId");
Assert.assertEquals(8, net.size());
Set<Email> emails = net.findEntitySet(Email.class, new Path(User.class).where("id='u1' or id='u2'").autoPath(Email.class));
Assert.assertEquals(4, emails.size());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetDemoTest method testAutoPath.
@Test
public void testAutoPath() {
insertDemoData();
EntityNet net = ctx.netLoad(new User(), new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
Set<Privilege> privileges = net.findEntitySet(Privilege.class, new Path(User.class).where("id='u1' or id='u2'").autoPath(Privilege.class));
for (Privilege privilege : privileges) System.out.print(privilege.getId() + " ");
Assert.assertEquals(3, privileges.size());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetDemoTest method testAutoPathAndBind.
@Test
public void testAutoPathAndBind() {
insertDemoData();
EntityNet net = ctx.netLoad(new User(), new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
Set<Privilege> privileges = net.findEntitySet(Privilege.class, new Path(User.class).where("id='u1' or id='u2'").autoPath(Privilege.class));
for (Privilege privilege : privileges) System.out.print(privilege.getId() + " ");
Assert.assertEquals(3, privileges.size());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetDemoTest method testloadEntityNet.
@Test
public void testloadEntityNet() {
insertDemoData();
EntityNet net = ctx.netLoad(new User(), Email.class, Address.class, new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
Assert.assertEquals(37, net.size());
System.out.println(net.size());
List<User> users = net.getAllEntityList(User.class);
Assert.assertEquals(5, users.size());
Assert.assertEquals("user1", users.get(0).getUserName());
System.out.println(users.get(0).getUserName());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetQueryTest method testFindChild.
@Test
public void testFindChild() {
System.out.println("==============testFindChild================ ");
int sampleSize = 30;
int queyrTimes = 30;
for (int i = 0; i < sampleSize; i++) {
new User().put("id", "usr" + i).put("userName", "user" + i).insert();
for (int j = 0; j < sampleSize; j++) new Email().put("id", "email" + i + "_" + j, "userId", "usr" + i).insert();
}
EntityNet net = ctx.netLoad(new User(), Email.class);
Map<Class<?>, Set<Node>> result = null;
long start = System.currentTimeMillis();
start = System.currentTimeMillis();
for (int i = 0; i < queyrTimes; i++) {
result = net.findNodeMapByEntities(new Path("S+", User.class).setCacheable(false).nextPath("C+", Email.class, "userId").setCacheable(false));
}
printTimeUsed(start, "Find Childs no Cache");
System.out.println("user selected2:" + result.get(User.class).size());
System.out.println("email selected2:" + result.get(Email.class).size());
net.setAllowQueryCache(true);
start = System.currentTimeMillis();
for (int i = 0; i < queyrTimes; i++) {
result = net.findNodeMapByEntities(new Path("S+", User.class).nextPath("C+", Email.class, "userId"));
}
printTimeUsed(start, "Find Childs with Cache");
System.out.println("user selected2:" + result.get(User.class).size());
System.out.println("email selected2:" + result.get(Email.class).size());
}
Aggregations