[Hibernate-JIRA] Created: (HHH-3078) Problem with multiple classloaders and cglib proxy enhancement, e.g. in the usual tomcat configuration
by Pietu Pohjalainen (JIRA)
Problem with multiple classloaders and cglib proxy enhancement, e.g. in the usual tomcat configuration
------------------------------------------------------------------------------------------------------
Key: HHH-3078
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3078
Project: Hibernate3
Issue Type: Bug
Components: build
Affects Versions: 3.2.5, 3.1.3
Environment: Verified against Hibernate 3.1.3 and Hibernate 3.2.5ga.
Reporter: Pietu Pohjalainen
Attachments: hibernate-3.2.patch, LoadOrderTest.tar.gz
In an usual tomcat classloader configuration, with hibernate3.jar residing in the Tomcat's common class loader and webapplications staying in their own classloaders, the cglib's proxy enhancement fails sometimes, as it tries to load the web application's classes via the Tomcat's common class loader.
The main culprit is the interaction between Hibernate's PojoEntityTuplizer and cglib's AbstractClassGenerator.
PojoEntityTuplizer passes a Set of interfaces to cglib for proxy enhancement. The set is constructed in method buildProxyFactory(PersistentClass, Getter, Setter). Now, depending on the interface classes hash codes, the order of included interfaces varies: sometimes Hibernate's HibernateProxy.class is the first one, sometimes it is the enhanced interface's class.
Problems rise when the Set's iterator gives the interfaces in order of {HibernateProxy.class, InterfaceToBeEnhanced.class}. When performing the enhancing, the cglib chooses the first interface class's classloader to find all the other classes as well. Because HibernateProxy.class was loaded by Tomcat's common class loader, it cannot find the application's class InterfaceToBeEnhanced. Thus a ClassDefNotFoundError is thrown.
There's a JUnit test demonstrating the case. Because the hashCodes of loaded classes is quite undeterministic (read: beyond my skills to make deterministic), I've included ten interface classes that should be cglib-enhanced. Most often, one of these enhancements fails, due to this bug.
A fix would be to change hibernate to prioritize the application's interface classes over Hibernate's HibernateProxy.class in the set. This could be implemented by using LinkedHashSet instead of HashSet, and adding the HibernateProxy.class as the last one. This change does not introduce any faults to existing unit test sets, but allows the attaches JUnit test to run without failures. The attached patch is for Hibernate 3.2.5ga.
--
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-3511) Sybase - Column alias in subselect doesn't works
by Juraci Paixao Krohling (JIRA)
Sybase - Column alias in subselect doesn't works
------------------------------------------------
Key: HHH-3511
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3511
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: Branch_3_2_4_SP1_CP with Sybase 15
Reporter: Juraci Paixao Krohling
I could not find any reference in documentation to support it, but it seems that column aliasing in sub-selects isn't supported. I could not find any information in the docs which confirms or denies this, but running the test CriteriaQueryTest#testDetachedCriteriaAsSubQuery can confirm this.
Hibernate generates a query which ends in:
where ? in (select this_.courseCode as y0_ from Course this_ where this_.description like ?)
This fails in Sybase, with this message:
15:29:38,063 WARN JDBCExceptionReporter:77 - SQL Error: 156, SQLState: ZZZZZ
15:29:38,074 ERROR JDBCExceptionReporter:78 - Incorrect syntax near the keyword 'AS'.
Removing all "as" keywords returns the same message, even though the query itself doesn't have it. [1]
Removing the "as $alias" solves the problem.
The working line is:
where courseCode in (select this_.courseCode from Course this_ where this_.description like 'test%')
--
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] Commented: (HHH-1528) GenericJDBCException when querying on one-to-one association
by Arne Limburg (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1528?page=c... ]
Arne Limburg commented on HHH-1528:
-----------------------------------
I guess the empty implementation of nullSaveSet(...) has to do with insertion of (in your example) Persons. On insertion no id for the name has to be set because of the primary key join-column. However I get thi9s error, too, when using another join-column than the primary key. I guess on the OneToOneType should be used on insertion and the ManyToOneType on selection.
> GenericJDBCException when querying on one-to-one association
> ------------------------------------------------------------
>
> Key: HHH-1528
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1528
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.1.2
> Environment: Hibernate 3.1.2, MySQL 4.1, Java 5
> Reporter: Alexander Dvorkovyy
> Attachments: src.zip
>
>
> I am getting following stack trace:
> Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
> at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.loader.Loader.doList(Loader.java:2148)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at BugDemo.main(BugDemo.java:28)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
> Caused by: java.sql.SQLException: Statement parameter 1 not set.
> at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1031)
> at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:676)
> at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> 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:2145)
> ... 13 more
> while executing this code:
> OneClass one = (OneClass) session.load(OneClass.class, 1L);
> Query query = session.createQuery("FROM OneToOneClass oto WHERE oto.whatever=:whatever");
> query.setParameter("whatever", one);
> query.list(); // < - - Exception is thrown here
> on this domain model (I used annotations here, same thing with hbm.xml):
> @Entity public class OneClass {
> @Id private Long id;
> }
> @Entity public class OneToOneClass {
> @Id private Long id;
> @OneToOne
> @PrimaryKeyJoinColumn
> private OneClass whatever;
> }
> Problem first appeared in 3.1 (also when using xml mapping files), in 3.0 no problem. Full source code attached.
> Would be nice if the problem can be fixed in upcoming 3.1.3
--
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, 12 months
[Hibernate-JIRA] Created: (HHH-2077) Providing an escape sequence for Criteria queries
by Tobias Dietl (JIRA)
Providing an escape sequence for Criteria queries
-------------------------------------------------
Key: HHH-2077
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2077
Project: Hibernate3
Type: Improvement
Components: query-criteria
Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3, 3.2.0.cr4
Environment: Hibernate 3.1.3, MySQL, HSQLDB, Oracle
Reporter: Tobias Dietl
Up to now, there is no way of setting the escape sequence to use for string comparisions with like for Criteria queries.
This is necessary as MySQL on the one hand and HSQLDB / Oracle on the other behave differently...
If you want to search for '_abc' in MySQL, you have to use:
value like '\\_abc'
In Oracle or HsqlDB, you have to use:
value like '\_abc'
If you want to switch to another escape sequence like '|' , you can set it in HQL with value like '|_abc' escape '|'. Unfortunately, there is no way of setting it for Criteria queries, which would force me to rewrite all my Criteria queries in HQL. It would really be nice if the feature/improvement would be added...
--
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, 12 months