Could the problem be caused by this issue with Derby?
-
http://issues.apache.org/jira/browse/DERBY-84
We are looking at using Derby ourselves (embedded in a fat client), and this is one of the major issues we need to address if we're going to use it.
We haven't done any work on analysing the potential effects of this defect, but it seems like it might be a major showstopper with regard to the use of Derby and Hibernate.
On the resolution front, it looks like the Derby developers are going with the old "well, we're conformant to the spec, even if it means those kinds of queries are unusable now". Similar to their position on not supporting unique constraints on nullable columns.
If you need those kinds of queries, I'm not sure what the path forward from here is.
Looks like the Hibernate guys will not be changing the way Hibernate uses column aliases for one database; and the Derby devs don't seem to want to change their support for column aliases to be in line with that of other major databases.
Stalemate.