The fields mapped in the entity are supposed to match with what you really have in the database tables. It seems you have an association between the above entity and EntityThree, but not between this entity and SubEntity. So this non-existing association at the DB level should not exist at the entity level either.
But your entities may have methods, that can navigate into the graph of entities:
public List<SubEntity> getSubEntities() {
List<SubEntity> result = Lists.newArrayListWithExpectedSize(samples.size());
for (EntityThree sample : samples) {
result.add(sample.getSubEntity());
}
return result;
}
or, in a functional way:
public Iterable<SubEntity> getSubEntities() {
return Iterables.transform(samples, new Function<EntityThree, SubEntity>() {
@Override
public SubEntity apply(EntityThree input) {
return input.getSubEntity();
}
});
}
You may also use a query:
select sub from MyEntity m
inner join m.samples sample
inner join sample.subEntity sub
where m.id = :theId