-->
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: Polymorphic resultset using SQLServer 2005
PostPosted: Wed Apr 04, 2007 7:39 pm 
Newbie

Joined: Fri Mar 09, 2007 2:57 pm
Posts: 3
Location: Cold Canada
I'm having an issue executing a search for all polymorphic types using the Criteria API.

I have the following classes:
- AbstractClassA
- ClassB extends AbstractClassA
- ClassC extends AbstractClassA

AbstractClassA has properties of type TEXT

Code:
Criteria criteria = session.createCriteria(AbstractClassA .class, "ae");
List results = criteria.list();


Unfortuantely
SQLServer 2005 spits out the exection:
Quote:
SEVERE: The text data type cannot be selected as DISTINCT because it is not comparable.
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at ...


The resulting sql is actually a union on the tables that represent ClassB and ClassC. On the microsoft forum this is listed as an issue, does anyone have a work around?

http://forums.microsoft.com/MSDN/ShowPo ... 7&SiteID=1

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 3:49 pm 
Newbie

Joined: Fri Mar 09, 2007 2:57 pm
Posts: 3
Location: Cold Canada
Ok,

I found the answer in a previous post in the forum.
http://forum.hibernate.org/viewtopic.php?t=971583

Apparently, the problem can circumvented by extending the SQLServerDialect Class.

Code:
public class MOSQLServerDialect extends SQLServerDialect {

    public boolean supportsUnionAll() {
        return true;
    }
}


Then simply ensure you specify the new dialect in your Hibernate.cfg.xml

Enjoy.


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.