use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetQueryTest method testAddEntity.
@Test
public void testAddEntity() {
System.out.println("==============testAddEntity================ ");
new User().put("id", "u1").put("userName", "user1").insert();
EntityNet net = ctx.netLoad(User.class);
Assert.assertEquals(1, net.size());
User u2 = new User();
u2.setId("u2");
u2.setUserName("user2");
u2.insert();
ctx.netAddEntity(net, u2);
Assert.assertEquals(2, net.size());
User u = net.getOneEntity(User.class, "u2");
Assert.assertEquals("user2", u.getUserName());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetTreeTest method testSearchTreeChild.
@Test
public void testSearchTreeChild() {
EntityNet net = ctx.netLoad(TreeNode.class);
Set<TreeNode> TreeNodes = net.findEntitySet(TreeNode.class, new Path("S+", TreeNode.class).where("id=? or id=?", "B", "D").nextPath("C*", TreeNode.class, "pid"));
for (TreeNode node : TreeNodes) System.out.print(node.getId() + " ");
Assert.assertEquals(9, TreeNodes.size());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityListHandler method handleResult.
@Override
public Object handleResult(QueryRunner query, Object result) {
List<Map<String, Object>> list = (List) sqlMapListHandler.handleResult(query, result);
EntityNet net = ((SqlBoxContext) query).netCreate(list);
return net.getAllEntityList(targetClass);
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetDemoTest method testAutoPath2.
@Test
public void testAutoPath2() {
insertDemoData();
EntityNet net = ctx.netLoad(new Email(), new User(), new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
Set<Privilege> privileges = net.findEntitySet(Privilege.class, new Path(Email.class).setValidator(new EmailValidator()).autoPath(Privilege.class));
for (Privilege privilege : privileges) System.out.println(privilege.getId());
Assert.assertEquals(1, privileges.size());
}
use of com.github.drinkjava2.jsqlbox.entitynet.EntityNet in project jSqlBox by drinkjava2.
the class EntityNetDemoTest method testNetLoadSketch.
@Test
public void testNetLoadSketch() {
insertDemoData();
EntityNet net = ctx.netLoadSketch(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(null, users.get(0).getUserName());
}
Aggregations