use of org.hibernate.jpa.test.metamodel.Entity2 in project hibernate-orm by hibernate.
the class FetchAndJoinTest method testImplicitJoinFromExplicitCollectionJoin.
@Test
public void testImplicitJoinFromExplicitCollectionJoin() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
final CriteriaBuilder builder = em.getCriteriaBuilder();
final CriteriaQuery<Entity1> criteria = builder.createQuery(Entity1.class);
final Root<Entity1> root = criteria.from(Entity1.class);
// illegal with fetch join
final Join<Entity1, Entity2> entity2Join = root.join(Entity1_.entity2, JoinType.INNER);
// <=== REMOVE
final Fetch<Entity1, Entity2> entity2Fetch = root.fetch(Entity1_.entity2, JoinType.INNER);
// <=== REMOVE
entity2Fetch.fetch(Entity2_.entity3);
criteria.where(builder.equal(root.get(Entity1_.value), "test"), // illegal with fetch join
builder.equal(entity2Join.get(Entity2_.value), "test"));
em.createQuery(criteria).getResultList();
em.getTransaction().commit();
em.close();
}
Aggregations