[Hibernate-JIRA] Created: (ANN-651) Bad SQL generated when using the @OrderBy annotation
by Eyal Lupu (JIRA)
Bad SQL generated when using the @OrderBy annotation
----------------------------------------------------
Key: ANN-651
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-651
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate Annotations 3.3.0.GA
Hibernate 3.2.5
EntityManager 3.3.1.GA
Hibernate Validator 3.0.0.GA
Oracle 10g
Reporter: Eyal Lupu
Attachments: orderBy-bug-test-case.zip
When upgrading to the versions above a code which works for months now stopped working, the reason is that Hibernate generates a bad SQL statment.
Attached is a test case:
Having the following classes
Parent
/ \
Child1 Child2
The parent has a property named 'elementType'. Child1 has a list of Child2 (its sibling) which is ordered using the
@OrderBy("elementType") annotation. When fetching a Child1 instance, using the EntityManager.find(...) method, Hibernate generates an
invalid SQL:
Hibernate: /* load bug.Child1 */ select child1x0_.ID as ID0_1_, child1x0_.ELEMENT_TYPE as ELEMENT3_0_1_, elements1_.PARENT_ID as PARENT4_3_, elements1_.ID as ID3_, elements1_.ID as ID0_0_, elements1_.ELEMENT_TYPE as ELEMENT3_0_0_, elements1_.PARENT_ID as PARENT4_0_0_ from BUG_TST child1x0_ left outer join BUG_TST elements1_ on child1x0_.ID=elements1_.PARENT_ID where child1x0_.ID=? and child1x0_.DTYPE='Child1' order by BUG_TST.ELEMENT_TYPE asc
The error is in the order by clause, you can't use the table name if you gave it an alias - you should use the alias.
* If I move the 'elementType' property down to Child2 it works!
*If I remove the @OrderBy it also works
-- It is hard to know if this is an Hibernate core or Hibernate annotation bug.
This is the exception:
Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [bug.Child1#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:175)
... 1 more
Caused by: java.sql.SQLException: ORA-00904: "BUG_TST"."ELEMENT_TYPE": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
... 13 more
-- Attached is a test case
--
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-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, 3 months
[Hibernate-JIRA] Created: (HHH-2933) DialectFactory dialects should be in a properties file
by Mikael Kopteff (JIRA)
DialectFactory dialects should be in a properties file
------------------------------------------------------
Key: HHH-2933
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2933
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.5
Reporter: Mikael Kopteff
Currently the DialectFactory has the static attribute MAPPERS, that hold the dialects. If the dialect is not found, Hibernate will throw an exception. There is already an TODO tag, set for this.So, could this be possibly done, so that the values really are a) in a properties file or b)additions could be made to the map programmaticaly by users.
This would be more flexible for advanced users, that work with experimental jdbc drivers(that don't return a standard name for the database).
The current trunk version of DialectFactory:
// TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
private static final Map MAPPERS = new HashMap();
static {
MAPPERS.put( "HSQL Database Engine", new VersionInsensitiveMapper( "org.hibernate.dialect.HSQLDialect" ) );
MAPPERS.put( "H2", new VersionInsensitiveMapper( "org.hibernate.dialect.H2Dialect" ) );
MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.hibernate.dialect.MySQLDialect" ) );
etc.....
--
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: (HSEARCH-232) Using SnowballPorterFilterFactory throws NoClassDefFoundError
by Hardy Ferentschik (JIRA)
Using SnowballPorterFilterFactory throws NoClassDefFoundError
-------------------------------------------------------------
Key: HSEARCH-232
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-232
Project: Hibernate Search
Issue Type: Bug
Reporter: Hardy Ferentschik
Assignee: Hardy Ferentschik
Fix For: 3.1.0.Beta2
Trying to use SnowballPorterFilterFactory in @AnalyzerDef will currently throw the following exception:
java.lang.NoClassDefFoundError: org/apache/solr/request/QueryResponseWriter
at org.apache.solr.analysis.SnowballPorterFilterFactory.init(SnowballPorterFilterFactory.java:42)
The problem is SnowballPorterFilterFactory contains a log statement using SolrCore.log.fine(). SolrCore itself has then a whole list of other import statements including QueryResponseWriter. Within Hibernate Search we use a custom/shrinked version of the solr jar which only contains the classes needed for analysis. QueryResponseWriter should of course not be required (see http://repository.jboss.org/maven2/org/hibernate/apache/lucene/solr/apach...).
The problem does not occur when the full solr jar is used.
We need to start a discussion with the solr developers regrading this logging issue.
Example annotation causing the error:
@AnalyzerDef(name="customanalyzer",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class,params = {
@Parameter(name="language", value= "English")
}),
})
--
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-3310) Using Nested DetachedCriteria (Sub-Selects) throwing NullPointerException
by Roshan Dawrani (JIRA)
Using Nested DetachedCriteria (Sub-Selects) throwing NullPointerException
-------------------------------------------------------------------------
Key: HHH-3310
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3310
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5, Oracle 10g
Reporter: Roshan Dawrani
Attachments: Nested_Subselects.zip
Hi,
We have come across an issue with the usage of nested subselects in the sql query with hibernate 3.2.5.
We get the following exception when there is more than one level of sub-selects in the query :
----------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException
at org.hibernate.criterion.SubqueryExpression.getTypedValues(SubqueryExpression.java:80)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getQueryParameters(CriteriaQueryTranslator.java:251)
at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:55)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:71)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at NestedDetachedCriteriaTest.testNestedDetachedCriteria(Unknown Source)
----------------------------------------------------------------------------------------------------------------------
The actual query that gets fired is like:
----------------------------------------------------------------------------------------------------------------------
select this_.name as y0_ from cat this_ where this_.name =
(select this0__.name as y0_ from cat this0__ where this0__.parent_id =
(select this0__.parent_id as y0_ from cat this0__ where this0__.name =
(select this0__.name as y0_ from cat this0__ where this0__.cat_id = ?)))
----------------------------------------------------------------------------------------------------------------------
We investigated the issue and have fixed it by making some changes in org.hibernate.criterion.SubqueryExpression class.
The attached file has the following contents:
1. SubqueryExpression.java - Fix we have made to SubqueryExpression class.
2. NestedDetachedCriteriaTest.zip - A test case to highlight the nested sub-select issue (testNestedDetachedCriteria).
Regards,
Roshan
--
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