[Hibernate-JIRA] Commented: (HHH-892) HQL parser does not resolve alias in ORDER BY clause
by Miguel Diaz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=co... ]
Miguel Diaz commented on HHH-892:
---------------------------------
This issue affects more cases than a simple ORDER BY:
SELECT a, (SELECT sum(b.x) FROM MyClass2 b WHERE b.parent = a) computed
FROM MyClass1 a
WHERE computed = 0 or computed is null
since 'computed' is used twice in the WHERE clause the workaround would be to duplicate the subquery, but that would have a performance impact.
I think this is not an uncommon use case so this issue deserves more (well, some at least) attention.
Thanks in advance.
> HQL parser does not resolve alias in ORDER BY clause
> -----------------------------------------------------
>
> Key: HHH-892
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-892
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.0.5
> Environment: Hibernate 3.0.5, MySQL, Tomcat
> Reporter: Guido Laures
> Priority: Minor
>
> When using an alias for an ORDER BY clause this is not always correctly resolved. Example:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY mySum
> does not work because "mySum" is not resolved in the ORDER BY clause which results in an exception telling that mySum is an unknown column.
> Workaround (not to say "hack") is using:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY col_0_0_
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 3 months
[Hibernate-JIRA] Commented: (HHH-1476) Table.qualify does not handle dialect diferences
by Krashan Brahmanjara (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1476?page=c... ]
Krashan Brahmanjara commented on HHH-1476:
------------------------------------------
Patch seems to work in 3.2.5.ga but is table.internalIdentifier neccesery?
It is used in two places cfg/Mappings and hdm2ddl/Databasemetadat, why?
Below solution will be compatiblie with Eclipse plugins
Table.java
public static String qualify(String catalog, String schema, String table) {
return dialect.qualify( usedCatalog, usedSchema, quotedName );
}
> Table.qualify does not handle dialect diferences
> ------------------------------------------------
>
> Key: HHH-1476
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1476
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Environment: Hibernate 3.1.2
> SQL Server 2000
> Reporter: Justin Kolb
> Attachments: informix-table-qname-patch-NPAC-vs-v324sp1.diff, informix-table-qname-patch-NPAC.diff, informix-table-qname-patch.diff
>
>
> The fix for HHH-699 caused me to discover that Hibernate isn't handling qualifying table names properly. It can be inferred from HHH-699 that not all databases are similar in this respect so I think this should be added to the dialect handling. From my short research I have the following 3 cases:
> SQL Server: database.owner.table
> MySQL: database.table (no schemas it seems)
> Most others: catalog.schema.table
> SQL Server also allows for "database..table" since it does not have schemas but does allow you to write queries that cross databases similar to how you can cross schemas in other database servers.
> Testing on Postgres though I determined that it does not allow "catalog..table" and will only accept "catalog.schema.table", so it dos not match up with SQL Server in this respect. If you write "catalog.table" it thinks you are trying to use a schema so it does not match up with MySQL in this respect.
> So right now only MySQL and SQL Server are the non standard compliant databases. Before 3.1 beta 1, SQL Server was handled correctly; then after that only MySQL was handled correctly.
> I'm not sure how much work it would take to make this change.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 3 months
[Hibernate-JIRA] Created: (HHH-2293) HQL Query with fetch causes exception if no rows selected be query (java.sql.SQLException: Exhausted Resultset )
by Andriy Solonchuk (JIRA)
HQL Query with fetch causes exception if no rows selected be query (java.sql.SQLException: Exhausted Resultset )
----------------------------------------------------------------------------------------------------------------
Key: HHH-2293
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2293
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: Oracle 10g2 (10.2.0.2.0) Hiberbate 3.2.0
Reporter: Andriy Solonchuk
After executing next query
select p from ProductHibernate p left join FETCH p.productSomeCollection
where 1=2 /* that will cause NO rows returned*/
we will have exception
org.hibernate.exception.GenericJDBCException: could not perform sequential read of results (forward)
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
...
Caused by: java.sql.SQLException: Exhausted Resultset
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
...
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1088)
at org.hibernate.loader.Loader.loadSequentialRowsForward(Loader.java:375)
... 24 more
If we will review code of Loader.java class we can see next
if ( resultSet.isAfterLast() ) {
// don't even bother trying to read further
return null;
}
if ( resultSet.isBeforeFirst() ) {
resultSet.next();
}
So at this step there are no checking if resultSet has any rows...
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
16 years, 3 months
[Hibernate-JIRA] Created: (HHH-3056) Exception with empty resultset in HQL query containing join fetch of collection
by Tony Lin (JIRA)
Exception with empty resultset in HQL query containing join fetch of collection
-------------------------------------------------------------------------------
Key: HHH-3056
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3056
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Environment: Windows XP sp2, Java 1.6.03, Tomcat 5.5.25
Reporter: Tony Lin
Attachments: object.zip
When performing this query on the attached model:
select subset from com.alphait.domain.snomed.object.SubsetImpl as subset join fetch subset.members as members left join fetch members.parent where subset.id = -1
We received the following exception:
org.hibernate.exception.GenericJDBCException: could not perform sequential read of results (forward)
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadSequentialRowsForward(Loader.java:398)
at org.hibernate.impl.FetchingScrollableResultsImpl.next(FetchingScrollableResultsImpl.java:55)
at org.hibernate.impl.FetchingScrollableResultsImpl.first(FetchingScrollableResultsImpl.java:200)
...
Caused by: java.sql.SQLException: Illegal operation on empty result set.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:713)
at com.mysql.jdbc.ResultSet.getLong(ResultSet.java:2850)
at com.mysql.jdbc.ResultSet.getLong(ResultSet.java:2845)
at com.mysql.jdbc.ResultSet.getLong(ResultSet.java:2960)
at org.hibernate.type.LongType.get(LongType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1097)
at org.hibernate.loader.Loader.loadSequentialRowsForward(Loader.java:387)
After investigating the source code, we found two places are problematic:
1. org.hibernate.loader.Loader's loadSequentialRowsForward method:
if (resultSet.isAfterLast() ) {
// don't even bother trying to read further
return null;
}
if (resultSet.isBeforeFirst() ) {
resultSet.next();
}
Both isBeforeFirst(), and isAfterLast() returnd false if the resultset is empty, so the code after these statements are executed before next() is called. we added the following lines to fix this problem:
if (resultSet.getRow() < 1) {
return null;
}
2. In org.hibernate.impl.FetchingScrollableResultsImpl's next() method, it aways returns true unless maxPosition is set. Should it be something like the following?
Object row = getLoader().loadSequentialRowsForward(
getResultSet(),
getSession(),
getQueryParameters(),
false
);
if (row == null) {
return false;
}
.....
We have not set scroll with other position yet.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 3 months