Re: [Hibernate] Criteria curiosity...

2005-01-31 Thread Max Rydahl Andersen
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


RE: [Hibernate] Criteria curiosity...

2005-01-28 Thread Steve Ebersole
Not sure which DB you are using, but for example I've noticed that HSQL
seems to not parse the entire statement string upfront which can lead to
issue like this.  It leaves parsing certain pieces relative to its
internal working datasets; if there are no results in those working
sets, you get no errors.  Specifically I have seen this with correlated
sub-queries.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Max
Rydahl Andersen
Sent: Friday, January 28, 2005 9:56 AM
To: Hibernate development
Subject: [Hibernate] Criteria curiosity...

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


---
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


RE: [Hibernate] Criteria curiosity...

2005-01-28 Thread Steve Ebersole
Sorry, since you did not explicitly say, just assumed you meant a db
error.

Can't tell you why this breaks as I have not looked at that projection
stuff.  I would guess that it is not *properly* resolving the return
types until there is actually a result set.

-Original Message-
From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 28, 2005 2:30 PM
To: Steve Ebersole; Hibernate development
Subject: Re: [Hibernate] Criteria curiosity...


but this check is something hibernate generates. its not db dependent  
AFAIK.


 Not sure which DB you are using, but for example I've noticed that
HSQL
 seems to not parse the entire statement string upfront which can lead
to
 issue like this.  It leaves parsing certain pieces relative to its
 internal working datasets; if there are no results in those working
 sets, you get no errors.  Specifically I have seen this with
correlated
 sub-queries.


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Max
 Rydahl Andersen
 Sent: Friday, January 28, 2005 9:56 AM
 To: Hibernate development
 Subject: [Hibernate] Criteria curiosity...

 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 ?




-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


---
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


Re: [Hibernate] Criteria curiosity...

2005-01-28 Thread Max Rydahl Andersen
Can't tell you why this breaks as I have not looked at that projection
stuff.  I would guess that it is not *properly* resolving the return
types until there is actually a result set.
yes got that, but i was just wondering if this is expected/wanted behavior.
/max
-Original Message-
From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]
Sent: Friday, January 28, 2005 2:30 PM
To: Steve Ebersole; Hibernate development
Subject: Re: [Hibernate] Criteria curiosity...
but this check is something hibernate generates. its not db dependent
AFAIK.

Not sure which DB you are using, but for example I've noticed that
HSQL
seems to not parse the entire statement string upfront which can lead
to
issue like this.  It leaves parsing certain pieces relative to its
internal working datasets; if there are no results in those working
sets, you get no errors.  Specifically I have seen this with
correlated
sub-queries.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Max
Rydahl Andersen
Sent: Friday, January 28, 2005 9:56 AM
To: Hibernate development
Subject: [Hibernate] Criteria curiosity...
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 ?



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
---
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


Re: [Hibernate] Criteria curiosity...

2005-01-28 Thread Gavin King
I guess this is the database, not us
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 ?


--
Gavin King
+61 410 534 454
+1 404 822 8349
callto://gavinking
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


Re: [Hibernate] Criteria curiosity...

2005-01-28 Thread Max Rydahl Andersen
but this check is something hibernate generates. its not db dependent  
AFAIK.


Not sure which DB you are using, but for example I've noticed that HSQL
seems to not parse the entire statement string upfront which can lead to
issue like this.  It leaves parsing certain pieces relative to its
internal working datasets; if there are no results in those working
sets, you get no errors.  Specifically I have seen this with correlated
sub-queries.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Max
Rydahl Andersen
Sent: Friday, January 28, 2005 9:56 AM
To: Hibernate development
Subject: [Hibernate] Criteria curiosity...
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 ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
---
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