[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3415) Bugs in some Criteria-Expressions!
Gail Badner (JIRA)
noreply at atlassian.com
Fri Aug 15 19:55:06 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3415?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gail Badner resolved HHH-3415.
------------------------------
Resolution: Duplicate
> Bugs in some Criteria-Expressions!
> ----------------------------------
>
> Key: HHH-3415
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3415
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.2.6, 3.3.0.CR1
> Environment: javase 5, postgresql 8
> Reporter: Max Hartmann
>
> I think there is a bug in some Criteria-Criterions:
> e.g. NotNullExpression:
> When I make an AliasProjection with the same name as the propertyName of the NotNullExpression, hibernate throws an exception.
> I think this exception occurs because referencing aliases in the WHERE-CLAUSE are not alowed in SQL (NotNullExpression.toSQLString() invokes CriteriaQuery.getColumnsUsingProjection() to use aliases for the where-clause).
> Code:
> List<?> result = s.createCriteria(Test.class, "t1")
> .createCriteria("test1", "t2")
> .add(Restrictions.isNotNull("id"))
> .setProjection(Projections.distinct(Projections.property("t2.id").as("id")))
> .list();
> Generated SQL:
> select distinct t2x1_.id as y0_ from test this_ inner join test t2x1_ on this_.id=t2x1_.test1_id where y0_ is not null
> Exception:
> Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.loader.Loader.doList(Loader.java:2208)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2102)
> at org.hibernate.loader.Loader.list(Loader.java:2097)
> at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:96)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1573)
> at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
> at org.hibernate.impl.CriteriaImpl$Subcriteria.list(CriteriaImpl.java:458)
> at test.TestApplication.main(TestApplication.java:52)
> Caused by: org.postgresql.util.PSQLException: ERROR: column "y0_" does not exist
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:184)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1785)
> at org.hibernate.loader.Loader.doQuery(Loader.java:674)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
> at org.hibernate.loader.Loader.doList(Loader.java:2205)
> ... 7 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list