-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: SQL Collation conflict on list sizing in HQL -class hierachy
PostPosted: Thu Nov 08, 2007 7:55 am 
Newbie

Joined: Thu Nov 08, 2007 7:23 am
Posts: 2
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]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 08, 2007 8:53 am 
Newbie

Joined: Thu Nov 08, 2007 7:23 am
Posts: 2
Apologies - been a bit stupid.

I'd checked to see if the collation was the same between the two different dbs in the mappings straight away, but I obviously didn't look closely enough.

The first query worked correctly because there was no SQL generated accessing both dbs in the same query, whereas the second query ran into collation issues when accessing dbs of different collations (which I had missed).

So I'm going to have to change the collation of one of the db's - unless:

Is it possible to state a collation as part of an HQL query?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.