[Hibernate-JIRA] Created: (HHH-2258) Bad SQL Grammer: Implicit join when using r.fooClass.attributes[?]=?
by Darryl Miles (JIRA)
Bad SQL Grammer: Implicit join when using r.fooClass.attributes[?]=?
--------------------------------------------------------------------
Key: HHH-2258
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2258
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: MySQL server this has been tested with.
Reporter: Darryl Miles
Priority: Critical
Attachments: test_joinedmapfilter.zip
Please find this test case atteched to demonstrate the bug, maybe you can add to the hibernate distribution for future testing and piece of mind for me.
The error:
Testsuite: org.hibernate.test.joinedmapfilter.JoinedMapFilterTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.498 sec
Testcase: testJoinedMapFilter took 0.495 sec
Caused an ERROR
could not execute query
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:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.test.joinedmapfilter.JoinedMapFilterTest.testJoinedMapFilter(JoinedMapFilterTest.java:116)
at org.hibernate.test.TestCase.runTest(TestCase.java:250)
at org.hibernate.test.TestCase.runBare(TestCase.java:316)
Caused by: java.sql.SQLException: Unknown table 'productdet1_' in where clause
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1668)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
... 25 more
SELECT r FROM com.company.Toplevel AS r WHERE r.toplevel=? AND rec.productDetail.attributes[?]=?
Also my recent post: http://forum.hibernate.org/viewtopic.php?t=966374&start=0&postdays=0&post...
This testcase has been tested with 3.1.3 and 3.2.0-ga.
2nd problem:
There is also another situation in the testcase which I found through serendipity which causes a NPE inside hibernate because I misspelled "r" as "rec". Check out the commented out section and swap over the createQuery() lines to demonstrate that NPE.
--
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
15 years, 11 months
[Hibernate-JIRA] Created: (HHH-2281) CLONE -Calling Session.connection() generates java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
by Sergey Polzunov (JIRA)
CLONE -Calling Session.connection() generates java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2281
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2281
Project: Hibernate3
Type: Bug
Versions: 3.2.1
Environment: Hibernate checked out from trunk; revision 10717
Reporter: Sergey Polzunov
Calling Session.connection() always generates an exception. Here is the stacktrace I get from the attached test case:
Exception in thread "main" java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.hibernate.jdbc.BorrowedConnectionProxy.generateProxy(BorrowedConnectionProxy.java:56)
at org.hibernate.jdbc.ConnectionManager.borrowConnection(ConnectionManager.java:163)
at org.hibernate.jdbc.JDBCContext.borrowConnection(JDBCContext.java:111)
at org.hibernate.impl.SessionImpl.connection(SessionImpl.java:359)
at TestSession.main(TestSession.java:16)
Changing the Connection.class.getClassLoader() to BorrowedConnectionProxy.class.getClassLoader() on line 57 in the generateProxy() method solves the problem. I am not very familiar with class loaders so I don't know if this is likeley to cause other problems elsewhere. Removing the ConnectionWrapper.class from the PROXY_INTERFACES array in the org.hibernate.jdbc.BorrowedConnectionProxy also solves the problem, but I guess it was added for a reason.
--
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
[Hibernate-JIRA] Created: (HHH-2254) A query validation bug produces QueryException: "Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.id.parent = ?]"
by Hernan Liendo (JIRA)
A query validation bug produces QueryException: "Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.id.parent = ?]"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2254
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2254
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.2.0.ga
Environment: Hibernate 3.2 using Sybase. However this is not an environment caused problem. It's supposed to happen in every environment.
Reporter: Hernan Liendo
-- Short description ============================================================================ --
A query validation bug produces QueryException: "Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.id.parent = ?].
Both Parent and Child use composite keys.
-- Context ====================================================================================== --
Having composite keys for a Parent class and a Child class, I want to retrieve childs that belong to an specific Parent.
-- Parent Definition ============================================================================ --
public class Parent {
public ParentId ParentId;
...
}
public class ParentId {
private String idField1;
private int idField2;
...
}
// the parent mapping
<hibernate-mapping>
<class mutable="false" table="xx" name="Parent">
<composite-id class="ParentId" access="field" name="parentId">
<key-property column="idField1" access="field" name="idField1"/>
<key-property column="idField2" access="field" name="idField2"/>
</composite-id>
</class>
</hibernate-mapping>
-- Child Definition ============================================================================ --
public class Child {
public ChildId childId;
...
}
public class ChildId {
public Parent parent;
public String aditionalIdField;
...
}
// the mapping
<hibernate-mapping>
<class mutable="false" table="yyy" name="Child">
<composite-id class="ChildId" access="field" name="childId">
<key-many-to-one name="parent" class="Parent" access="field">
<column name="idField1" not-null="true" />
<column name="idField2" not-null="true" />
</key-many-to-one>
<key-property column="aditionalIdField" access="field" name="aditionalIdField"/>
</composite-id>
</class>
</hibernate-mapping>
-- HQL Statement ============================================================================ --
from Child this where this.childId.parent = ?
or
from Child this where this.id.parent = ? // using aliased id
-- The Exception ============================================================================ --
org.hibernate.QueryException: Expected positional parameter count: 1, actual parameters: [Parent@bec357b] [from Child this where this.childId.parent = ?]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:319)
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:275)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:75)
...
-- The Problem ============================================================================ --
class: org.hibernate.impl.AbstractQueryImpl
method: protected void verifyParameters(boolean reserveFirstParameter) throws HibernateException
line: 286
The method validates parameters. It resolves the "positionalValueSpan" variable witch in my case gets the value of 2 (One for parent's idField1 and the other for parent's idField2).
The method compares positionalValueSpan (2) with parameterMetadata.getOrdinalParameterCount() witch it is 1 (the quantity of "?" signs in the HQL statement".
This bug only happens when:
1. composed keys are used (and)
2. having a parent-child relationship (and)
3. resolving children from certain parent.
-- Hibernate user workaround ============================================================================ --
Not to use a parent instance variable in the Child class.
Hope this helps. If you guys need the source code in order to check the bug, please let me know it. Good luck!
Hernan
--
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