1 Reply Latest reply on May 16, 2017 2:09 PM by KIM TIAGO BAPTISTA

    Hibernate join fetching of nested entities fails after patching JBoss 6.4 to 6.4.6

    Carlos Lacerda Newbie

      I'm experiencing problem with fetch entitities in JBoss EAP 6.4 after upgrade from 6.4 to 6.4.6, when hibernate version upgrade from 4.2.18 to 4.2.22 this error appear.


      A simple sample that causes Error:

      Query of leagacy EJB application that runs fine before upgrade:
      SELECT a FROM EntityA a
      JOIN FETCH a.b b
      JOIN FETCH a.b.someAttr


      I know that this query maybe is not correct or according with the JPA Spec and now throws the following error after deploy application in JBoss 6.4.6:

      Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName= (...)


      Adjusted query to solve the problem:

      SELECT a FROM EntityA a

      JOIN FETCH a.b b

      JOIN FETCH b.someAttr

       

      Refactoring of code to fix queries is the best I know but it´s hard to solve because in my case I have a large legacy system with a lot of modules that use pre-compiled namedqueries and a lot of queries created on demand. To indentify and modify whole system and make changes where was working as well using a old version of hibernate is a very annoying work and error prone. The backward compatibility in this case would be nice to me, Even it can be a problem for new development I agree .


      To solve it I did a downgrade only of hibernate main module to initial default version 4.2.18 directly inside overlays created by upgrade, but this is not good because when the next patch of JBoss arrive I need to change it again. I´m trying use the JBoss modules and some configuration in persistence.xml and jboss-deployment-strcuture.xml but without success yet.


       

      Anyone already experienced this problem ?


      I already tried create a module using the version 4.2.18 of hibernate in a new Slot, changed persistence.xml to use it but the error persists anyway.


      Any help or tip will be very valualble.


      Thanks all.