On Sat, 29 Jan 2005 09:56:35 +1100, Gavin King <[EMAIL PROTECTED]> wrote:

I guess this is the database, not us

No - sorry for not attaching the stacktrace.

If the query matches something I get this error:

org.hibernate.QueryException: could not resolve property: courseCode of: org.hibernate.test.criteria.Student
at org.hibernate.persister.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.BasicEntityPersister.toType(BasicEntityPersister.java:1017)
at org.hibernate.loader.CriteriaQueryTranslator.getType(CriteriaQueryTranslator.java:352)
at org.hibernate.criterion.PropertyProjection.getTypes(PropertyProjection.java:36)
at org.hibernate.criterion.ProjectionList.getTypes(ProjectionList.java:38)
at org.hibernate.loader.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:250)
at org.hibernate.loader.CriteriaLoader.getResultColumnOrRow(CriteriaLoader.java:114)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:296)
at org.hibernate.loader.Loader.doQuery(Loader.java:375)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:195)
at org.hibernate.loader.Loader.doList(Loader.java:1361)
at org.hibernate.loader.Loader.list(Loader.java:1344)
at org.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:106)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1606)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:262)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:379)
at org.hibernate.impl.CriteriaImpl$Subcriteria.uniqueResult(CriteriaImpl.java:142)
at org.hibernate.test.criteria.CriteriaQueryTest.testProjections(CriteriaQueryTest.java:198)


If no result matches we don't get the error - which i think is a bit inconsistent (but probably also a bit more performant ;)

It's caused by getprojectedtypes not being called before an item is materialized.

/max




Max Rydahl Andersen wrote:

Hi,

while working on Critiera i "bumped" into this funny behavior:

Doing the following Critieria on an empty db gives no error:

s.createCriteria(Student.class)
            .add( Expression.like("name", "Gavin", MatchMode.START) )
            .addOrder( Order.asc("name") )
            .createCriteria("enrolments", "e")
                .addOrder( Order.desc("year") )
                .addOrder( Order.desc("semester") )
            .createCriteria("course")
                .addOrder( Order.asc("description") )
                .setProjection( Expression.projection()
                    .add( Expression.property("this.name") )
                    .add( Expression.property("e.year") )
                    .add( Expression.property("e.semester") )
                    .add( Expression.property("courseCode") )
                    .add( Expression.property("description") )
                )
            .uniqueResult();

but when data is available i get an error saying
that courseCode is not available on Student - which is totally correct. (using explicit criteria aliases solves it)


I'm just wondering why this is not discovered when the query gives no result - it should still be able to tell
that courseCode is not on Student - is this expected behavior ?







-- Max Rydahl Andersen callto://max.rydahl.andersen

Hibernate
[EMAIL PROTECTED]
http://hibernate.org

JBoss Inc
[EMAIL PROTECTED]
http://jboss.com


------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to