[Hibernate-JIRA] Created: (HHH-2119) reloading a detached object with a collection fails
by Gregory Kotsaftis (JIRA)
reloading a detached object with a collection fails
---------------------------------------------------
Key: HHH-2119
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2119
Project: Hibernate3
Type: Bug
Versions: 3.1.3
Environment: Hibernate 3.1.3
firebird 1.5.3.4870 with Jaybird-2.1.0
java 1.5.0_07
Reporter: Gregory Kotsaftis
Hi,
1) I have a simple object <O> with a collection loaded and use <version> for both (no second level cache)
2) The object <O> is associated with session A, via <O> = load(CLASS, <ID>)
3) The session <A> is later closed because e.g. an exception occurs
4) Another session is opened later on, session B
5) If load(<O>, <ID>) is called an NonUniqueObjectException is thrown
(a different object with the same identifier value was already associated with the session)
6) If instead I use the session.refresh(<O>) no exception is thrown, the object is reloaded ok.
It seems this issue might be related with:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-511
but i cannot be sure.
Part of the stacktrace:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [gr.metadata.orthomed.db.Patient#23]
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:132)
at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:202)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:169)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:770)
at gr.metadata.lib.hibernate.HibernateHelper.reloadObject(HibernateHelper.java:230)
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-2073) many-to-one join fetch with optional parent causing stray query to fire
by Adam Hardy (JIRA)
many-to-one join fetch with optional parent causing stray query to fire
-----------------------------------------------------------------------
Key: HHH-2073
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2073
Project: Hibernate3
Type: Bug
Reporter: Adam Hardy
Priority: Minor
Attachments: bugtest.zip
I have a call centre application which uses a mature database and is therefore pushing Hibernate to accomplish the mappings I need. The issue here is extra queries that Hibernate is firing where I set up the mapping to do a join in one hit.
I am fetching child objects which may or may not have a parent. The child's foreign key points to a non-primary key on the parent. This is not reflected by a foreign key constraint in the database (hence it allows child to have no parent).
If the child object has the foreign key 0 instead of null, which is the protocol in this database, then the parent which doesn't exist is not (& cannot) be instantiated, no problem, but then after processing the resultset, Hibernate fires off another query to fetch the parent that it could not find data for in the first query.
This is obviously unnecessary in this context and degrades the performance on large searches on this child.
I have classified it as minor since I suspect there may be work-arounds but I have not researched that yet.
I didn't know whether I could put the mapping XML in the query, so I have attached a simplistic testcase example that demonstrates the problem.
The following forum messages are relevant and the latter contains the mappings, which is easier than extracting them out of the testcase zip:
http://forum.hibernate.org/viewtopic.php?t=960522
http://forum.hibernate.org/viewtopic.php?t=964211
--
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, 9 months
[Hibernate-JIRA] Created: (HHH-2110) Proxied object causes ClassCastException when method returns 'this' in a composite hierarchy
by Philip Nightingale (JIRA)
Proxied object causes ClassCastException when method returns 'this' in a composite hierarchy
--------------------------------------------------------------------------------------------
Key: HHH-2110
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2110
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.0.5
Environment: Hibernate 3, any database (test case uses HSQL, issue found using Oracle)
Reporter: Philip Nightingale
Attachments: HibernateClassCastExceptionTest.zip
If a proxied object has a method that returns 'this' and the proxy type extends the same base class as the target object and the return type of the method is the target class type then a ClassCastException is thrown.
The error can be tracked down to the method CGLibLazyInitializer::intercept(Object, Method, Object[], MethodProxy).
In this method, if the object returned from the method call on the target object is the same as the target object, then instead of returning the object itself the proxy is returned. This is fine in most cases, but in the special case described, in which the proxy extends a base class that is also extended by the target class, then the CCE occurs.
In the submitted test case I have a simple composite hierarchy with an abstract base type and two concrete subtypes. Either type can contain children, but only one can be the root of the hierarchy (and cannot itslef be a child). There is a many-to-one relationship defined from the sub-type that may be a child to the base class.
The submitted test case is configured to use Hypersonic DB so hsqldb.jar is required on the classpath.
Further details and code snippets from the original code that caused the exception are posted on the Hibernate user forum (topic "ClassCastException with CGLIB Lazy Initialization")
--
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, 12 months