If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Right outer join syntax for Hibernate with My Sql 5.1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-30-09, 05:02
catch2karthik catch2karthik is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 06-30-09, 05:28
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-30-09, 06:04
catch2karthik catch2karthik is offline
Registered User
 
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 [
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On