use of io.requery.test.model.Group_Person in project requery by requery.
the class FunctionalTest method testFindByCompositeKey.
@Test
public void testFindByCompositeKey() {
Group group = new Group();
group.setName("group");
group.setType(GroupType.PRIVATE);
Person person = randomPerson();
person.getGroups().add(group);
data.insert(person);
assertTrue(person.getId() > 0);
// create the composite key
Map<Attribute<Group_Person, Integer>, Integer> map = new LinkedHashMap<>();
map.put(Group_Person.GROUPS_ID, group.getId());
map.put(Group_Person.PERSON_ID, person.getId());
CompositeKey<Group_Person> compositeKey = new CompositeKey<>(map);
Group_Person joined = data.findByKey(Group_Person.class, compositeKey);
assertNotNull(joined);
}
Aggregations