Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    Unanswered: Right outer join syntax for Hibernate with My Sql 5.1

    First i Tried this:
    Query in hbm.xml:

    <query name="QueryContractCountOnWorkStatus">
    <![CDATA[
    select
    ws.workStatusType,count(cd.contractId),ws.workStat usId
    from
    WorkStatus ws,ContractDetails cd
    where
    cd.projectId =?
    and
    ws.workStatusId = * cd.workStatusId

    group by ws.workStatusType,ws.workStatusId,ws.statusNew
    order by ws.statusNew

    ]]>
    </query>

    Exception as follows:
    com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=contractde1_.Work_Status_ID ) group by workstatus0_.Work_Status_Type , worksta' at line 1

    Second Try:
    <query name="QueryContractCountOnWorkStatus">
    <![CDATA[
    select
    ws.workStatusType,count(cd.contractId),ws.workStat usId
    from
    ContractDetails cd right join WorkStatus ws
    where
    cd.projectId =?
    and
    ws.workStatusId = cd.workStatusId

    group by ws.workStatusType,ws.workStatusId,ws.statusNew
    order by ws.statusNew

    ]]>
    </query>

    Exception as follows:
    net.sf.hibernate.QueryException: outer or full join must be followed by path expression

    plz urgent... Thanks in Advance

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT ws.workStatusType
         , ws.workStatusId 
         , ws.statusNew
         , COUNT(cd.contractId)
      FROM WorkStatus AS ws
    LEFT OUTER
      JOIN ContractDetails AS cd
        ON cd.workStatusId = ws.workStatusId
       AND cd.projectId = ? 
    GROUP 
        BY ws.workStatusType
         , ws.workStatusId 
         , ws.statusNew
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2009
    Posts
    2

    Hi Thanks but its not working for hiberante

    Quote Originally Posted by r937
    Code:
    SELECT ws.workStatusType
         , ws.workStatusId 
         , ws.statusNew
         , COUNT(cd.contractId)
      FROM WorkStatus AS ws
    LEFT OUTER
      JOIN ContractDetails AS cd
        ON cd.workStatusId = ws.workStatusId
       AND cd.projectId = ? 
    GROUP 
        BY ws.workStatusType
         , ws.workStatusId 
         , ws.statusNew
    i Tried but i am getting same excpetion

    net.sf.hibernate.QueryException: outer or full join must be followed by path expression [

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •