[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1830?page=c...
]
Tim McCune commented on HHH-1830:
---------------------------------
Sorry, I spent 4 hours digging through the code yesterday trying to come up with a patch,
and there is a ridiculous amount of code involved. Without a lot of context, I don't
know how effective I will be at this. Creating a test case should be easy enough.
It's very straight-forward to demonstrate the bug. Have you tried to repro this and
failed, or are you just looking for low-hanging fruit? If it's the former, let me
know and I will create a test case. FWIW, here is my debug log and stack trace:
2008-02-01 09:58:43,488 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl]
(http-127.0.0.1-8080-1) parse() - HQL: select queue.id from com.linebuster.common.Queue
queue join queue.authorizedTicketTakers t, com.linebuster.common.Employee employee where
employee in elements(t) and employee.account.userid = :principal
2008-02-01 09:58:43,494 DEBUG [org.hibernate.hql.ast.AST] (http-127.0.0.1-8080-1) --- HQL
AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | +-[RANGE] 'RANGE'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[IDENT] 'com'
| | | | | | \-[IDENT] 'linebuster'
| | | | | \-[IDENT] 'common'
| | | | \-[IDENT] 'Queue'
| | | \-[ALIAS] 'queue'
| | +-[JOIN] 'join'
| | | +-[DOT] '.'
| | | | +-[IDENT] 'queue'
| | | | \-[IDENT] 'authorizedTicketTakers'
| | | \-[ALIAS] 't'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[IDENT] 'com'
| | | | | \-[IDENT] 'linebuster'
| | | | \-[IDENT] 'common'
| | | \-[IDENT] 'Employee'
| | \-[ALIAS] 'employee'
| \-[SELECT] 'select'
| \-[DOT] '.'
| +-[IDENT] 'queue'
| \-[IDENT] 'id'
\-[WHERE] 'where'
\-[AND] 'and'
+-[IN] 'in'
| +-[IDENT] 'employee'
| \-[IN_LIST] 'inList'
| \-[ELEMENTS] 'elements'
| \-[IDENT] 't'
\-[EQ] '='
+-[DOT] '.'
| +-[DOT] '.'
| | +-[IDENT] 'employee'
| | \-[IDENT] 'account'
| \-[IDENT] 'userid'
\-[COLON] ':'
\-[IDENT] 'principal'
2008-02-01 09:58:43,494 DEBUG [org.hibernate.hql.ast.ErrorCounter] (http-127.0.0.1-8080-1)
throwQueryException() : no errors
2008-02-01 09:58:43,494 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker]
(http-127.0.0.1-8080-1) select << begin [level=1, statement=select]
2008-02-01 09:58:43,495 DEBUG [org.hibernate.hql.ast.tree.FromElement]
(http-127.0.0.1-8080-1) FromClause{level=1} : com.linebuster.common.Queue (queue) ->
queue0_
2008-02-01 09:58:43,495 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode]
(http-127.0.0.1-8080-1) Resolved : queue -> queue0_.id
2008-02-01 09:58:43,495 DEBUG [org.hibernate.hql.ast.tree.DotNode] (http-127.0.0.1-8080-1)
getDataType() : authorizedTicketTakers ->
org.hibernate.type.SetType(com.linebuster.common.Queue.authorizedTicketTakers)
2008-02-01 09:58:43,496 DEBUG [org.hibernate.hql.ast.tree.FromElementFactory]
(http-127.0.0.1-8080-1) createManyToMany() : path = queue.authorizedTicketTakers role =
com.linebuster.common.Queue.authorizedTicketTakers associatedEntityName =
com.linebuster.common.Employee
2008-02-01 09:58:43,496 DEBUG [org.hibernate.hql.ast.tree.FromElement]
(http-127.0.0.1-8080-1) FromClause{level=1} : com.linebuster.common.Employee (t) ->
employee2_
2008-02-01 09:58:43,496 DEBUG [org.hibernate.hql.ast.tree.FromClause]
(http-127.0.0.1-8080-1) addJoinByPathMap() : queue.authorizedTicketTakers -> Employee
employee2_
2008-02-01 09:58:43,496 DEBUG [org.hibernate.hql.ast.tree.DotNode] (http-127.0.0.1-8080-1)
dereferenceCollection() : Created new FROM element for queue.authorizedTicketTakers :
QueueTicketTaker employee2_
2008-02-01 09:58:43,496 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode]
(http-127.0.0.1-8080-1) Resolved : queue.authorizedTicketTakers -> .
2008-02-01 09:58:43,497 DEBUG [org.hibernate.hql.ast.HqlSqlWalker] (http-127.0.0.1-8080-1)
createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'QueueTicketTaker employee2_'
FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy
properties,classAlias=t,role=com.linebuster.common.Queue.authorizedTicketTakers,tableName=Employee,tableAlias=employee2_,origin=Queue
queue0_,colums={queue0_.id ,className=com.linebuster.common.Employee}}
2008-02-01 09:58:43,497 DEBUG [org.hibernate.hql.ast.tree.FromElement]
(http-127.0.0.1-8080-1) FromClause{level=1} : com.linebuster.common.Employee (employee)
-> employee3_
2008-02-01 09:58:43,497 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode]
(http-127.0.0.1-8080-1) Resolved : queue -> queue0_.id
2008-02-01 09:58:43,497 DEBUG [org.hibernate.hql.ast.tree.DotNode] (http-127.0.0.1-8080-1)
getDataType() : id -> org.hibernate.type.LongType@46ccf
2008-02-01 09:58:43,497 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode]
(http-127.0.0.1-8080-1) Resolved : queue.id -> queue0_.id
2008-02-01 09:58:43,498 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode]
(http-127.0.0.1-8080-1) Resolved : employee -> employee3_.id
2008-02-01 09:58:43,502 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode]
(http-127.0.0.1-8080-1) Resolved : t -> employee2_.id
2008-02-01 09:58:43,502 DEBUG [org.hibernate.hql.ast.tree.MethodNode]
(http-127.0.0.1-8080-1) Creating elements for t[].elements
2008-02-01 09:58:43,505 ERROR [com.linebuster.server.AuthenticatorBean]
(http-127.0.0.1-8080-1) System exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -5
at java.lang.String.substring(String.java:1938)
at java.lang.String.substring(String.java:1905)
at
org.hibernate.hql.CollectionSubqueryFactory.createCollectionSubquery(CollectionSubqueryFactory.java:32)
at org.hibernate.hql.ast.tree.FromElementType.toColumns(FromElementType.java:300)
at org.hibernate.hql.ast.tree.FromElementType.toColumns(FromElementType.java:290)
at org.hibernate.hql.ast.tree.FromElement.toColumns(FromElement.java:390)
at org.hibernate.hql.ast.tree.MethodNode.handleElements(MethodNode.java:162)
at
org.hibernate.hql.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:109)
at
org.hibernate.hql.ast.tree.CollectionFunction.resolve(CollectionFunction.java:22)
at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:834)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunction(HqlSqlBaseWalker.java:2558)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4245)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4161)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3842)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at
org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
at
org.jboss.ejb3.entity.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:134)
Error during parse query on MS SQL
----------------------------------
Key: HHH-1830
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1830
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.1.2, 3.2.0.cr2
Environment: Microsoft SQL Server 2000, Windows XP, JDK 1.5 Update 4
Reporter: Den Raskovalov
Priority: Critical
HQL: select deal, items.dateBegin, client.Title from " + CoreDeal.class.getName() +
" deal left join deal.stagesWorkflowInstance.history.items items, " +
CoreClient.class.getName() + " client where stageResponsible=:stageResponsible and
items.index=maxindex(items) and deal.parent=client and
deal.stagesWorkflowInstance.Stage.showOnPersonalPage=1
It works normally on Oracle, but on MS SQL produces:
Error: String index out of range: -5
[java.lang.StringIndexOutOfBoundsException]
java.lang.String.substring(String.java:1768)
java.lang.String.substring(String.java:1735)
org.hibernate.hql.CollectionSubqueryFactory.createCollectionSubquery(CollectionSubqueryFactory.java:32)
org.hibernate.hql.ast.tree.FromElementType.toColumns(FromElementType.java:301)
org.hibernate.hql.ast.tree.FromElementType.toColumns(FromElementType.java:291)
org.hibernate.hql.ast.tree.FromElement.toColumns(FromElement.java:377)
org.hibernate.hql.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:115)
org.hibernate.hql.ast.tree.MethodNode.collectionProperty(MethodNode.java:95)
org.hibernate.hql.ast.tree.MethodNode.resolve(MethodNode.java:44)
org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:844)
org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:2324)
org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1285)
org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4032)
org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3521)
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1686)
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1683)
org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1683)
org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:227)
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:159)
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)
org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1612)
ru.naumen.crm2.bobjects.deal.CoreDealHibernateHandler.listAllDealsWithSortDataByResponsible(CoreDealHibernateHandler.java:109)
ru.naumen.crm2.ui.tlc.CoreEmployeeTableListController.listMyDealsSorted(CoreEmployeeTableListController.java:70)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
--
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