[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-3707) Generate wrong CRUD SQL for joined-subclasses of union-subclass
by David Wang (JIRA)
Generate wrong CRUD SQL for joined-subclasses of union-subclass
---------------------------------------------------------------
Key: HHH-3707
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3707
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate V3.2.6, Oracle 11g
Reporter: David Wang
Attachments: src.zip
We use extension table to customerize our base line. Create one joined-subclass to the existed union-subclass in the project. For simple, I create simple sample to demo the error. UnionTableOne and UnionTableTwo are union-subclass of UnionTable. UnionTableOneExt is joined-subclass of UnionTableOne. See the attached files. Here list the hebernate mapping file.
<hibernate-mapping package="union">
<class name="UnionTable" entity-name="UnionTable" abstract="true">
<id name="unionId" type="java.lang.Integer">
<column name="UNION_ID" />
<generator class="assigned" />
</id>
</class>
<union-subclass name="UnionTableOne" extends="UnionTable" entity-name="UnionTableOne" table="uniontableone">
<property name="oneName" column="ONE_NAME"></property>
</union-subclass>
<union-subclass name="UnionTableTwo" extends="UnionTable" entity-name="UnionTableTwo" table="uniontabletwo">
<property name="twoName" column="TWO_NAME"></property>
</union-subclass>
<joined-subclass name="UnionTableOneExt" extends="UnionTableOne" entity-name="UnionTableOneExt" table="uniontableone_ext">
<key column="UNION_ID"></key>
<property name="extName" column="EXT_NAME"></property>
</joined-subclass>
</hibernate-mapping>
When I create one UnionTableOneExt object, the generated SQL is
insert into uniontableone_ext (ONE_NAME, EXT_NAME, UNION_ID) values (?, ?, ?);
--
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-1570) criteria-api: filtering by key-many-to-one causes invalid sql
by Sanchit Srivastava (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1570?page=c... ]
Sanchit Srivastava commented on HHH-1570:
-----------------------------------------
I am using 3.2.6.ga version of hibernate and am still finding this issue...
So i am unable to move along the association using a key-many-to-one association from table A to B (A contains composite key pointing to B and C tables)
I tried using both criteria.createAlias and criteria.createCriteria ..... Using createAlias, as pointed out earlier, is creeating a wrong query (where clause b.property=? is created but the table B is missing from 'from clause' ).
However createCriteria is not even creating the where clause...
Do we have a fix for this on way or the Hibernate team is still working ... I find that the issue is still open, with no fix version specified.. so I assume this true.... Please can you provide a statuc on this?
Regards & Thanks
> criteria-api: filtering by key-many-to-one causes invalid sql
> -------------------------------------------------------------
>
> Key: HHH-1570
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1570
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.1.2
> Reporter: Joris Verschoor
> Attachments: hibernate.patch
>
>
> We have a class Price that has a composite-id using a couple of key-properties and some key-many-to-ones)
> One of those is "transportation", which has a many-to-one to transportationType
> When we query using: criteria.add(Expression.eq("price.transportation.transportationType.id", transId);, we get an invalid SQL statement: The table of transportation was not selected.
> I will try to make a testcase today or tomorrow, depending on my schedule.. Things will be more clear by then...
> We have created a work-around, by mapping the transportationID twice: once in key-property, and once as a many-to-one. (instead of one key-many-to-one)
--
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