public void testNoIdQuery() {

    Update<NoIdEntity> upd = Ebean.createUpdate(NoIdEntity.class, "delete from NoIdEntity");
    upd.execute();

    NoIdEntity e0 = new NoIdEntity();
    e0.setId(1);
    e0.setValue("one");

    NoIdEntity e1 = new NoIdEntity();
    e1.setId(2);
    e1.setValue("two");

    Ebean.save(e0);
    Ebean.save(e1);

    List<NoIdEntity> list = Ebean.createNamedQuery(NoIdEntity.class, "noid").findList();

    Assert.assertEquals(2, list.size());
    NoIdEntity noIdEntity0 = list.get(0);
    Assert.assertNotNull(noIdEntity0);
    Assert.assertEquals(noIdEntity0.getValue(), "one");

    NoIdEntity noIdEntity1 = list.get(1);
    Assert.assertNotNull(noIdEntity1);
    Assert.assertEquals(noIdEntity1.getValue(), "two");
  }
  @Test
  public void test() {

    Ebean.createUpdate(Permission.class, "delete from Permission").execute();
    Ebean.createUpdate(Tenant.class, "delete from Tenant").execute();
    Ebean.createUpdate(Role.class, "delete from Role").execute();

    Tenant t = new Tenant("tenant");

    Ebean.save(t);

    Permission p1 = new Permission("p1");
    Permission p2 = new Permission("p2");

    Ebean.save(p1);
    Ebean.save(p2);

    Role role1 = new Role("role");
    role1.setTenant(t);

    Set<Permission> permissions = new HashSet<Permission>();
    List<Permission> permsList = Ebean.find(Permission.class).findList();
    permissions.addAll(permsList);

    role1.setPermissions(permissions);

    Ebean.save(role1);

    List<Tenant> tenantList = Ebean.find(Tenant.class).fetch("roles").findList();
    List<Role> roleList = Ebean.find(Role.class).fetch("permissions").findList();
    List<Permission> permissionList = Ebean.find(Permission.class).fetch("roles").findList();

    Assert.assertEquals(1, tenantList.size());
    Assert.assertEquals(2, permissionList.size());
    Assert.assertEquals(1, roleList.size());

    Ebean.delete(role1);

    List<Tenant> tenantList2 = Ebean.find(Tenant.class).fetch("roles").findList();
    List<Role> roleList2 = Ebean.find(Role.class).fetch("permissions").findList();
    List<Permission> permissionList2 = Ebean.find(Permission.class).fetch("roles").findList();

    Assert.assertEquals(0, roleList2.size());
    Assert.assertEquals(1, tenantList2.size());
    Assert.assertEquals(2, permissionList2.size());
  }