Re: MS SQL Server: Select Distinct on text datatype

From: Lachlan Deck (lachlan.dec..mail.com)
Date: Mon Aug 04 2008 - 03:49:15 EDT

  • Next message: Matthias Moeser: "Re: MS SQL Server: Select Distinct on text datatype"

    Hi there,

    On 04/08/2008, at 5:39 PM, Andrey Razumovsky wrote:

    > This is definitely MS SQL's issue, not Cayenne's. Only thing I can
    > recommend, if you can allow that, select all rows and then seed
    > out duplicate rows manually

    AFAIK we are not purposely turning on the flag for obtaining distinct
    rows. (Well to be fair - we don't have the root stack trace from ROP
    so can't be certain if we are or not).

    But AFAIK Cayenne does turn certain queries into select distinct
    (e.g., joins). Is that right?

    > 2008/8/4, Matthias Moeser <matthia..sh.com.au>:
    >>
    >> We are using Cayenne with Microsoft SQL Server. We get a
    >> com.microsoft.sqlserver.jdbc.SQLServerException: "The text data
    >> type cannot
    >> be selected as DISTINCT because it is not comparable."
    >>
    >> The problem is that the following query is not allowed in MS SQL
    >> Server:
    >>
    >> SELECT DISTINCT column FROM table;
    >>
    >> where "column" is of datatype "text". So i think that cayenne does
    >> somewhere such a DISTINCT query on a "text" datatype column.
    >>
    >> The datatype "text" in MS SQL server is a variable-length data with a
    >> maximum length of 2^31 - 1 (2,147,483,647) characters, Varchar()
    >> can have
    >> only maximum 8000 character.
    >>
    >> What can I do? I need the "text" datatype.
    >>
    >> Thank you
    >> Matthias
    >>
    >>
    >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    >> at
    >> org.mortbay.jetty.bio.SocketConnector
    >> $Connection.run(SocketConnector.jav
    >> a:228)
    >> at
    >> org.mortbay.thread.BoundedThreadPool
    >> $PoolThread.run(BoundedThreadPool.ja
    >> va:450)
    >> Caused by: java.lang.Exception: The text data type cannot be
    >> selected as
    >> DISTINCT because it is not comparable.
    >> com.microsoft.sqlserver.jdbc.SQLServerException: The text data type
    >> cannot be selected as DISTINCT because it is not comparable.
    >> at
    >> com
    >> .microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Un
    >> known Source)
    >> at
    >> com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown
    >> Source)
    >> at
    >> com
    >> .microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePrepare
    >> dStatement(Unknown Source)
    >> at
    >> com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement
    >> $PrepStmtExecCmd.
    >> doExecute(Unknown Source)
    >> at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown
    >> Source)
    >> at
    >> com
    >> .microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown
    >> Source)
    >> at
    >> com
    >> .microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown
    >> Source)
    >> at
    >> com
    >> .microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown
    >> Source)
    >> at
    >> com
    >> .microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unk
    >> nown Source)
    >> at
    >> org
    >> .apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.j
    >> ava:73)
    >> at
    >> org
    >> .apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryActi
    >> on.java:58)
    >>

    with regards,

    --
    

    Lachlan Deck



    This archive was generated by hypermail 2.0.0 : Mon Aug 04 2008 - 03:49:57 EDT