Batch fetching doing N+1 Query when NamedQuery is called after a NativeQuery in JBoss EAP 7
Issue
Batch fetching doing N+1 Query
when NamedQuery
is called after a NativeQuery
inside a transaction in the JBoss EAP 7
List<MyEntity> myEntities = entityManager.createNamedQuery(MyEntity.FIND_ALL, MyEntity.class).getResultList();
String sql = "select u.* from MyEntity u";
Query nativeQuery = entityManager.createNativeQuery(sql);
logger.info("############# Executing Native Query #####################");
List<MyEntity> myEntityNativeQuery = nativeQuery.getResultList();
//myEntity.myEntityTwo is configured with @BatchSize .
for(MyEntity entity : myEntities){
entity.getMyEntityTwo().size();
}
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
- Hibernate 5
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.