2 Replies Latest reply on May 12, 2010 5:03 AM by hoetzl.maximilian

    JPA association with FetchMode.JOIN

      Hi,

       

      I'm encountering a strange issue that might be due to my own stupidity but I can't figure out why

       

      I have a class Order that has a one-to-many association to another class Item. The relationship works fine. My fetchType is set to eager. I'm trying to test different @Fetch annotations and see the results.

       

      When I specify a specific fetch mode, it works fine if I do a entityManager.find(X) on my Order class. The JOIN fetch mode will perform a join as desired.

       

      When I fetch using a named query, for example getOrderByDate (not using a Criteria), I cannot get the JOIN to work. I will either get several SQL statements, or sub-selects if I specify that as my FetchMode.

       

      Is there something specific to do in order to enable JOIN as a fetchMode for named queries or is it only supported when find() is used?

       

      Thanks in advance,

       

      Greg