Hibernate version:
3
Mapping documents:
See below
Full stack trace of any exception that occurs:
Hibernate operation: could not execute query; uncategorized SQLException for SQL [select siebelserv0_.SR_NUMBER as SR1_121_ ......where siebelserv0_.SR_PR_ORG_NAME=? and (select count(surveys1_.case_ref) from ( select Q14, case_ref, 1 as clazz_ from dbSurvey.dbo.tbl__ResultsItServiceDeskSurvey ) surveys1_ where siebelserv0_.SR_NUMBER=surveys1_.case_ref)>0]; SQL state [S1000]; error code [446]; Cannot resolve collation conflict for equal to operation.
Name and version of the database you are using:
SQL Server 2000
The generated SQL (show_sql=true):
[select siebelserv0_.SR_NUMBER as SR1_121_ ......(select count(surveys1_.case_ref) from ( select Q14, case_ref, 1 as clazz_ from dbSurvey.dbo.tbl__ResultsItServiceDeskSurvey ) surveys1_ where siebelserv0_.SR_NUMBER=surveys1_.case_ref)>0]
Hi all,
I've been researching this for several hours with no sucess - it may be due to a lack of knowledge of HQL, but I've reached a dead end with documentation.
We are creating a small reporting app for a number of service desks internal to our company with the following object structure:
helpdesk -> holds a list collection of: SiebelServiceRequest (s) -> holds a list collection of: srSurvey (s)
As each helpdesk operates a different style of survey, this is an abstract class so I have the following mapping files for service request and survey:
Code:
<class name="SiebelServiceRequest" table="tblCSDMonthlyReport">
<id name="srNumber" type="string" column="SR_NUMBER">
<generator class="native"/>
</id>
.......
<bag name="surveys">
<key column="case_ref" />
<one-to-many class="SrSurvey"/>
</bag>
</class>
<class name="SrSurvey" abstract="true">
<id name="id" type="string" column="case_ref"></id>
<union-subclass name="ITSurvey"
table="tbl__ResultsItServiceDeskSurvey">
<property name="question" column="Q14" />
</union-subclass>
</class>
I have stripped out standard properties for easier reading. The second mapping shows that so far I have one class that extends the SrSurvey abstract class.
Note this is part of an intranet system that uses hibernate nearly exclusively, so I am happy with the code implementation.
The following works perfectly (to bring back all service requests for a particular helpdesk, with a survey list populated):
Code:
public List<SiebelServiceRequest> getSiebelServiceRequests(Helpdesk helpdesk) throws HelpdeskException {
return(ArrayList<SiebelServiceRequest>) getHibernateTemplate().find(
"from SiebelServiceRequest as sr " +
"where sr.helpdesk=? ",helpdesk);
}
however this:
Code:
public List<SiebelServiceRequest> getSiebelServiceRequests(Helpdesk helpdesk) throws HelpdeskException {
return(ArrayList<SiebelServiceRequest>) getHibernateTemplate().find(
"from SiebelServiceRequest as sr " +
"where sr.helpdesk=? " +
"and sr.surveys.size > 0",helpdesk);
}
errors with the sql exception given at the top of this post. As you can see I'm trying to only return service requests that have had a survey responded to - I have to do this in the HQL as the full service request list is enormous.
So I guess my questions are:
- Is my HQL correct to determine the size of a collection?
- If yes, does this HQL normally work with the hierachy I am trying to use?
- If yes, is there some additional SQL/HQL I need to specify to prevent what appears to be a SQL exception (rather than a Hibernate one)?
Thanks in advance![/code]