Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2010-06-01 06:58:23 +0000
committerMartin Taal2010-06-01 06:58:23 +0000
commit3b3cd132673ce6dd05d8f7cdfedbba42b371f56a (patch)
treee9dd6794b04770c2d3734c61ff753743e3b46c52 /plugins/org.eclipse.emf.cdo.server.hibernate
parente19dfda4bec40a841ed788893205c82d1cc7969b (diff)
downloadcdo-3b3cd132673ce6dd05d8f7cdfedbba42b371f56a.tar.gz
cdo-3b3cd132673ce6dd05d8f7cdfedbba42b371f56a.tar.xz
cdo-3b3cd132673ce6dd05d8f7cdfedbba42b371f56a.zip
fixes issue [310990] [Hibernate] Option for classes in hibernate mapping to be declared lazy
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java13
13 files changed, 71 insertions, 110 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index 1c7984bc32..00ca01208f 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -444,12 +444,12 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
{
value = null;
}
-
+
final String revisionName = (String)value;
final boolean match = exactMatch || revisionName == null || name == null ? ObjectUtil
.equals(revisionName, name) : revisionName.startsWith(name);
- if (match && !context.addResource(revision.getID()))
+ if (match && !context.addResource(HibernateUtil.getInstance().getCDOID(revision)))
{
// No more results allowed
break;
@@ -548,10 +548,6 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
final String entityName = getStore().getEntityName(revision.getEClass());
session.saveOrUpdate(entityName, revision);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Persisted new Object " + revision.getEClass().getName() + " id: " + revision.getID()); //$NON-NLS-1$ //$NON-NLS-2$
- }
}
session.flush();
@@ -571,11 +567,18 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
// delete all objects
for (CDOID id : context.getDetachedObjects())
{
- final CDORevision revision = HibernateUtil.getInstance().getCDORevision(id);
- // maybe deleted in parallell?
- if (revision != null)
+ try
+ {
+ final CDORevision revision = HibernateUtil.getInstance().getCDORevision(id);
+ // maybe deleted in parallell?
+ if (revision != null)
+ {
+ session.delete(revision);
+ }
+ }
+ catch (org.hibernate.ObjectNotFoundException ex)
{
- session.delete(revision);
+ // ignore these, an object can be removed through cascade deletes
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
index e6f821aaae..e65bebcef4 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
@@ -49,6 +49,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.hibernate.Session;
+import org.hibernate.proxy.HibernateProxy;
import java.io.Serializable;
import java.util.Map;
@@ -231,6 +232,39 @@ public class HibernateUtil
}
/**
+ * Checks if the object is a HibernateProxy. If so creates the CDOID without resolving the hibernate proxy. If it not
+ * a proxy then the id is retrieved from the object itself. It is assumed to be a CDORevision then.
+ */
+ public CDOID getCDOID(Object o)
+ {
+ if (o instanceof HibernateProxy)
+ {
+ final Object idValue = ((HibernateProxy)o).getHibernateLazyInitializer().getIdentifier();
+ final String entityName = ((HibernateProxy)o).getHibernateLazyInitializer().getEntityName();
+ final HibernateStoreAccessor accessor = HibernateThreadContext.getCurrentStoreAccessor();
+ final EClass eClass = accessor.getStore().getEClass(entityName);
+ return HibernateUtil.getInstance().createCDOID(new CDOClassifierRef(eClass), idValue);
+ }
+
+ return ((CDORevision)o).getID();
+ }
+
+ /**
+ * Reads the entity name while taking account the fact that the object maybe a Hibernate proxy.
+ */
+ public String getEntityName(Object o)
+ {
+ if (o instanceof HibernateProxy)
+ {
+ return ((HibernateProxy)o).getHibernateLazyInitializer().getEntityName();
+ }
+
+ final EClass eClass = ((CDORevision)o).getEClass();
+ final HibernateStoreAccessor accessor = HibernateThreadContext.getCurrentStoreAccessor();
+ return accessor.getStore().getEntityName(eClass);
+ }
+
+ /**
* Deprecated method use: {@link HibernateStore#getEntityName(EClass)}.
*/
@Deprecated
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java
index 4c6cc196af..f345c42d55 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.id.CDOIDExternal;
import org.eclipse.emf.cdo.common.id.CDOIDMeta;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
import org.hibernate.usertype.ParameterizedType;
import org.hibernate.usertype.UserType;
@@ -104,7 +105,7 @@ public class CDOIDExternalUserType implements UserType, ParameterizedType
final Object localValue;
if (value instanceof CDORevision)
{
- localValue = ((CDORevision)value).getID();
+ localValue = HibernateUtil.getInstance().getCDOID(value);
}
else
{
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
index f8584a7314..beca0c8baf 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
@@ -39,7 +39,7 @@ public class CDOIDPropertyGetter extends CDOPropertyGetter
public Object get(Object target) throws HibernateException
{
InternalCDORevision revision = (InternalCDORevision)target;
- if (!(revision.getID() instanceof CDOIDObject))
+ if (!(HibernateUtil.getInstance().getCDOID(revision) instanceof CDOIDObject))
{
if (!isVirtualProperty())
{
@@ -75,7 +75,7 @@ public class CDOIDPropertyGetter extends CDOPropertyGetter
private void setCDOID(CDORevision target, Object value)
{
final InternalCDORevision revision = (InternalCDORevision)target;
- final CDOID cdoID = revision.getID();
+ final CDOID cdoID = HibernateUtil.getInstance().getCDOID(revision);
if (cdoID == null || cdoID instanceof CDOIDTemp)
{
final CDOID newCDOID = HibernateUtil.getInstance().createCDOID(new CDOClassifierRef(revision.getEClass()), value);
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
index 9782e010a5..7f59e5c28a 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
@@ -50,7 +50,7 @@ public class CDOIDPropertySetter extends CDOPropertySetter
return;
}
- final CDOID revisionID = revision.getID();
+ final CDOID revisionID = HibernateUtil.getInstance().getCDOID(revision);
if (revisionID == null || revisionID instanceof CDOIDTemp)
{
final CDOID newCDOID = HibernateUtil.getInstance().createCDOID(new CDOClassifierRef(revision.getEClass()), value);
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
index c5f7e005f5..448b5a842d 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
@@ -97,7 +97,7 @@ public class CDOIDUserType implements UserType
final CDORevision revision = HibernateUtil.getInstance().getCDORevisionNullable((CDOID)value);
if (revision != null)
{
- value = revision.getID();
+ value = HibernateUtil.getInstance().getCDOID(revision);
}
}
else if (value instanceof CDORevision)
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java
index cfcb879782..58df309ca8 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java
@@ -13,11 +13,7 @@ package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateThreadContext;
import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
import org.hibernate.EmptyInterceptor;
import org.hibernate.type.Type;
@@ -46,7 +42,7 @@ public class CDOInterceptor extends EmptyInterceptor
}
final CDORevision revision = (CDORevision)entity;
- final CDOID cdoID = revision.getID();
+ final CDOID cdoID = HibernateUtil.getInstance().getCDOID(revision);
if (cdoID.isNull() || cdoID.isTemporary())
{
return true;
@@ -63,10 +59,7 @@ public class CDOInterceptor extends EmptyInterceptor
return object.getClass().getName();
}
- final InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(object);
-
- final EClass eClass = revision.getEClass();
- return HibernateThreadContext.getCurrentStoreAccessor().getStore().getEntityName(eClass);
+ return HibernateUtil.getInstance().getEntityName(object);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java
index f7564c3433..079eb600f6 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java
@@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
import org.eclipse.emf.cdo.common.id.CDOIDExternal;
import org.eclipse.emf.cdo.common.id.CDOIDMeta;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -43,8 +43,7 @@ public class CDOReferenceSetter extends CDOPropertySetter
}
else
{
- CDORevision cdoValue = (CDORevision)value;
- super.set(target, cdoValue.getID(), factory);
+ super.set(target, HibernateUtil.getInstance().getCDOID(value), factory);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
index 6be7c58c81..1764d53096 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
@@ -174,63 +174,6 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
}
}
- // MT: probably not required as the property getter/setter do all the work
- // /*
- // * (non-Javadoc)
- // *
- // * @see org.hibernate.tuple.entity.AbstractEntityTuplizer#getVersion(java.lang.Object)
- // */
- // @Override
- // public Object getVersion(Object entity) throws HibernateException
- // {
- // if (entity instanceof CDORevision)
- // {
- // final CDORevision cdoRevision = (CDORevision)entity;
- // return cdoRevision.getVersion();
- // }
- // throw new IllegalArgumentException("Entity of type: " + entity.getClass().getName()
- // + " not supported by this tuplizer");
- // }
- //
- // @Override
- // public Serializable getIdentifier(Object entity) throws HibernateException
- // {
- // if (entity instanceof CDORevision)
- // {
- // final CDOID cdoID = ((CDORevision)entity).getID();
- // if (cdoID instanceof CDOIDHibernate)
- // {
- // return ((CDOIDHibernate)cdoID).getId();
- // }
- // }
- // throw new IllegalArgumentException("Entity of type: " + entity.getClass().getName()
- // + " not supported by this tuplizer");
- // }
- //
- // @Override
- // public void setIdentifier(Object entity, Serializable id) throws HibernateException
- // {
- // if (entity instanceof InternalCDORevision)
- // {
- // final InternalCDORevision cdoRevision = (InternalCDORevision)entity;
- // final CDOID cdoID = cdoRevision.getID();
- // if (cdoID == null)
- // {
- // CDOIDHibernate hid = (CDOIDHibernate)HibernateStore.CDOID_OBJECT_FACTORY.createCDOIDObject(null);
- // hid.setId(id);
- // cdoRevision.setID(hid);
- // return;
- // }
- // else if (cdoID instanceof CDOIDHibernate)
- // {
- // ((CDOIDHibernate)cdoID).setId(id);
- // return;
- // }
- // }
- // throw new IllegalArgumentException("Entity of type: " + entity.getClass().getName()
- // + " not supported by this tuplizer");
- // }
-
public EClass getEClass()
{
return eClass;
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
index 51cca5f44d..42a140c9c0 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
@@ -60,12 +60,12 @@ public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAc
return null;
}
- if (!HibernateUtil.getInstance().isStoreCreatedID(revision.getID()))
+ if (!HibernateUtil.getInstance().isStoreCreatedID(HibernateUtil.getInstance().getCDOID(revision)))
{
return null;
}
- return HibernateUtil.getInstance().getIdValue(revision.getID());
+ return HibernateUtil.getInstance().getIdValue(HibernateUtil.getInstance().getCDOID(revision));
}
@SuppressWarnings("rawtypes")
@@ -98,7 +98,7 @@ public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAc
}
final InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(target);
- final CDOID cdoID = revision.getID();
+ final CDOID cdoID = HibernateUtil.getInstance().getCDOID(revision);
if (cdoID == null || cdoID instanceof CDOIDTemp)
{
final CDOID newCDOID = HibernateUtil.getInstance().createCDOID(new CDOClassifierRef(revision.getEClass()), value);
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
index 1f2829fdea..d82a0da16f 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
@@ -155,8 +155,7 @@ public class HibernateMoveableListWrapper implements MoveableList<Object>
return o;
}
- CDORevision cdoRevision = (CDORevision)o;
- return cdoRevision.getID();
+ return HibernateUtil.getInstance().getCDOID(o);
}
protected List<Object> getValues(Collection<?> c)
@@ -345,7 +344,7 @@ public class HibernateMoveableListWrapper implements MoveableList<Object>
public void add(Object o)
{
- delegate.add(((CDORevision)o).getID());
+ delegate.add(HibernateUtil.getInstance().getCDOID(o));
}
public boolean hasNext()
@@ -397,7 +396,7 @@ public class HibernateMoveableListWrapper implements MoveableList<Object>
public void set(Object o)
{
- delegate.set(((CDORevision)o).getID());
+ delegate.set(HibernateUtil.getInstance().getCDOID(o));
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
index 29956343eb..df419b8fe7 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
@@ -4,18 +4,13 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Martin Taal - copied from CDORevisionPropertyHandler and adapted
* Eike Stepper - maintenance
*/
package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
import org.eclipse.emf.ecore.EStructuralFeature;
import org.hibernate.collection.PersistentCollection;
@@ -31,8 +26,6 @@ import java.util.Map;
*/
public class PersistableListHolder
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, PersistableListHolder.class);
-
private static PersistableListHolder instance = new PersistableListHolder();
private static ThreadLocal<Map<Key, PersistentCollection>> listMapping = new ThreadLocal<Map<Key, PersistentCollection>>();
@@ -56,11 +49,6 @@ public class PersistableListHolder
}
getListMapping().put(key, collection);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Stored hb list in threadlocal: " + ((CDORevision)target).getEClass().getName() + "." //$NON-NLS-1$ //$NON-NLS-2$
- + feature.getName());
- }
}
public PersistentCollection getListMapping(Object target, EStructuralFeature feature)
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
index c3b493ee71..0d80e10c1c 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
@@ -24,6 +24,8 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.hibernate.proxy.HibernateProxy;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -175,8 +177,7 @@ public class WrappedHibernateList implements InternalCDOList
protected CDOID getCDOID(Object o)
{
- CDORevision cdoRevision = (CDORevision)o;
- return cdoRevision.getID();
+ return HibernateUtil.getInstance().getCDOID(o);
}
protected List<CDOID> getCDOIDs(Collection<?> c)
@@ -228,9 +229,9 @@ public class WrappedHibernateList implements InternalCDOList
public Object get(int index)
{
final Object value = getObject(getDelegate().get(index));
- if (value instanceof CDORevision)
+ if (value instanceof CDORevision || value instanceof HibernateProxy)
{
- return ((CDORevision)value).getID();
+ return HibernateUtil.getInstance().getCDOID(value);
}
if (value instanceof EEnumLiteral)
@@ -391,7 +392,7 @@ public class WrappedHibernateList implements InternalCDOList
public void add(Object o)
{
- delegate.add(((CDORevision)o).getID());
+ delegate.add(HibernateUtil.getInstance().getCDOID(o));
}
public boolean hasNext()
@@ -443,7 +444,7 @@ public class WrappedHibernateList implements InternalCDOList
public void set(Object o)
{
- delegate.set(((CDORevision)o).getID());
+ delegate.set(HibernateUtil.getInstance().getCDOID(o));
}
}
}

Back to the top