Search code examples
ormcoldfusionhqldistinctcoldfusion-9

Coldfusion ORM NTEXT type causing 'dbo' to be returned instead of object


I have a user object that was working fine until I added a new field to it for a description. The new field is of type 'NTEXT' and is defined as:

<cfproperty name="description" type="string" ormtype="text">

I have a HQL query that then does a search for distinct users who have a certain permission level in certain places. This query worked fine until the description field was added at which point it decided that it couldn't return a distinct user as you can't use distinct on NTEXT fields.

To get around this I nested the query so that it is looking for users where users id are in the nested query that now only selects distinct user id's instead of the whole user object.

This no longer throws an error but instead returns the string 'dbo' instead of the user object.

I have had a look at the HQL logs, copied the function out, replaced the objects with their db tables and inserted the parameter and the function behaves as it should in mssql manager.

Why would orm return dbo instead of the object and not give any further error? Does anyone know how to handle NTEXT fields so they don't cause these issues?


Solution

  • I was using

    SELECT USER
    

    in the hql query as it was originally

    SELECT DISTINCT USER
    

    This was sending the select straight to the DB which was returning the current user of the database instead of the user object.

    Removing the select line fixed the issue