[hibernate-dev] derby support

Steve Ebersole steve.ebersole at jboss.com
Tue Aug 1 13:25:02 EDT 2006


I am working on enhancing Derby support a little bit, but have run into
an issue with their syntax that I am unable to figure out.  I was hoping
someone on this list was familiar enough with Derby to point me in the
right direction.

Specifically, I am trying to properly deal with the manner in which
Derby (and also DB2 largely) expects columns to be referenced in certain
clauses.  For example, because Hibernate always aliases columns in the
select clause, derby requires that those aliases be used in certain
later clauses.  The query I am trying to work through right now is as
follows:
    select
        model0_.name as col_0_0_,
        count(*) as col_1_0_ 
    from
        Model model0_ 
    group by
        model0_.name 
    having
        count(*) > 1

However, I get errors from Derby when passing this to the DB:
ERROR 42X04: Column 'MODEL0_.COL_0_0_' is either not in any table in the
FROM list or appears within a join specification and is outside the
scope of the join specification or appears in a HAVING clause and is not
in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then
'MODEL0_.COL_0_0_' is not a column in the target table.

If the having clause is removed, the query parses fine; I have tried
various incantations regarding how to define the having clause without
avail.

This query seems taken almost verbatim from their reference docs, yet I
cannot get this to work...
http://db.apache.org/derby/docs/10.1/ref/rrefselectexpression.html

Any thoughts?




More information about the hibernate-dev mailing list