1 Reply Latest reply on May 27, 2011 8:51 AM by andres quijano

    Forcing left join

    gerryjun Newbie

      seam gen project



      is it possible to force hibernate to use left joins when generating the EJBQL from




      @Name("masterUserList")
      public class MasterUserList extends EntityQuery<MasterUser>





      below is the sql generated when i sort users based on client name where user has manny to one relationship with client table.


      to generate this


         


      SELECT *
          FROM
              MasterUser masteruser0_ LEFT JOIN
              MasterClient masterclie1_ 
          ON
              masteruser0_.ClientID=masterclie1_.ClientID 
          ORDER BY
              masterclie1_.ClientName ASC 
       




      instead of




          SELECT *
          FROM
              MasterUser masteruser0_,
              MasterClient masterclie1_ 
          Where
              masteruser0_.ClientID=masterclie1_.ClientID 
          ORDER BY
              masterclie1_.ClientName ASC 







        • 1. Re: Forcing left join
          andres quijano Newbie

          Please post your current code, it can be done with something like this:



          private static final String EJBQL = "select masteruser from MasterUser masteruser left join masteruser.client client";
          
          private static final String[] RESTRICTIONS = {
            "client = #{masterUserList.client}"
          };