Revision: 4200
http://openutils.svn.sourceforge.net/openutils/?rev=4200&view=rev
Author: gcatania
Date: 2013-03-12 08:58:39 +0000 (Tue, 12 Mar 2013)
Log Message:
-----------
BSHD-19 fixed for backport branch
Modified Paths:
--------------
branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java
branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java
Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java
===================================================================
--- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java 2013-03-11 15:45:30 UTC (rev 4199)
+++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java 2013-03-12 08:58:39 UTC (rev 4200)
@@ -37,6 +37,7 @@
import org.hibernate.criterion.Restrictions;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.proxy.HibernateProxy;
/**
@@ -184,11 +185,17 @@
String identifierName = classMetadata.getIdentifierPropertyName();
if (identifierName != null)
{
- // TODO is this cast really necessary? Will it fail in future hibernate versions?
- SessionImplementor si = (SessionImplementor) ses;
+ Object idValue;
+ // backport fix for BSHD-19 from Hibernate v4.1.10.Final
+ if (HibernateProxy.class.isInstance(entity))
+ {
+ idValue = ((HibernateProxy) entity).getHibernateLazyInitializer().getIdentifier();
+ }
+ else
+ {
+ idValue = classMetadata.getIdentifier(entity, ses.getEntityMode());
+ }
- // Object idValue = classMetadata.getIdentifier(entity, si);
- Object idValue = classMetadata.getIdentifier(entity, ses.getEntityMode());
if (idValue != null) // TODO should we use property selectors instead?
{
crit.add(Restrictions.idEq(idValue));
Modified: branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java
===================================================================
--- branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java 2013-03-11 15:45:30 UTC (rev 4199)
+++ branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java 2013-03-12 08:58:39 UTC (rev 4200)
@@ -113,10 +113,7 @@
testFindLazy(1L, "foo1_2");
}
- /**
- * FIXME enable this test and fix BSHD-19
- */
- @Test(enabled = false)
+ @Test
public void testFindWithLazyParent2()
{
testFindLazy(1L, "fooX_X");
@@ -132,10 +129,7 @@
testDontFind(fooStr, bar1);
}
- /**
- * FIXME enable this test and fix BSHD-19
- */
- @Test(enabled = false)
+ @Test
public void testDontFindWithLazyParent()
{
long barId = 1L;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|