Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2008-06-15 20:47:36 +0000
committerMartin Taal2008-06-15 20:47:36 +0000
commitc6067967bdc948c0bbe613e3895a970f447e7327 (patch)
tree5f2925446e855f267550074299320700ad340def /plugins
parent8190469dbd94372336b91781ee436eddf8b6af19 (diff)
downloadcdo-c6067967bdc948c0bbe613e3895a970f447e7327.tar.gz
cdo-c6067967bdc948c0bbe613e3895a970f447e7327.tar.xz
cdo-c6067967bdc948c0bbe613e3895a970f447e7327.zip
Added check on null commitcontext
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java22
3 files changed, 48 insertions, 26 deletions
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 73f13fa81e..37d5de5b41 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
@@ -111,24 +111,27 @@ public class HibernateUtil
return null;
}
- HibernateCommitContext hcc = HibernateThreadContext.getHibernateCommitContext();
- CDORevision revision;
- if ((revision = hcc.getDirtyObject(id)) != null)
+ if (HibernateThreadContext.isHibernateCommitContextSet())
{
- return revision;
- }
- if ((revision = hcc.getNewObject(id)) != null)
- {
- return revision;
- }
+ HibernateCommitContext hcc = HibernateThreadContext.getHibernateCommitContext();
+ CDORevision revision;
+ if ((revision = hcc.getDirtyObject(id)) != null)
+ {
+ return revision;
+ }
+ if ((revision = hcc.getNewObject(id)) != null)
+ {
+ return revision;
+ }
- // maybe the temp was already translated
- if (id instanceof CDOIDTemp)
- {
- CDOID newID = hcc.getCommitContext().getIDMappings().get(id);
- if (newID != null)
+ // maybe the temp was already translated
+ if (id instanceof CDOIDTemp)
{
- return getCDORevision(newID);
+ CDOID newID = hcc.getCommitContext().getIDMappings().get(id);
+ if (newID != null)
+ {
+ return getCDORevision(newID);
+ }
}
}
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 270efa4207..bdfc2947c9 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
@@ -43,8 +43,11 @@ public class CDOIDPropertySetter extends CDOPropertySetter
return;
}
- final HibernateCommitContext hcc = HibernateThreadContext.getHibernateCommitContext();
-
+ HibernateCommitContext hcc = null;
+ if (HibernateThreadContext.isHibernateCommitContextSet())
+ {
+ hcc = HibernateThreadContext.getHibernateCommitContext();
+ }
InternalCDORevision revision = (InternalCDORevision)target;
CDOID cdoID = revision.getID();
if (cdoID == null)
@@ -52,15 +55,21 @@ public class CDOIDPropertySetter extends CDOPropertySetter
CDOIDHibernate newCDOID = CDOIDHibernateFactoryImpl.getInstance().createCDOID((Serializable)value,
revision.getCDOClass().getName());
revision.setID(newCDOID);
- hcc.setNewID(cdoID, newCDOID);
+ if (hcc != null)
+ {
+ hcc.setNewID(cdoID, newCDOID);
+ }
}
else if (cdoID instanceof CDOIDTemp)
{
CDOIDHibernate newCDOID = CDOIDHibernateFactoryImpl.getInstance().createCDOID((Serializable)value,
revision.getCDOClass().getName());
revision.setID(newCDOID);
- hcc.getCommitContext().addIDMapping((CDOIDTemp)cdoID, newCDOID);
- hcc.setNewID(cdoID, newCDOID);
+ if (hcc != null)
+ {
+ hcc.getCommitContext().addIDMapping((CDOIDTemp)cdoID, newCDOID);
+ hcc.setNewID(cdoID, newCDOID);
+ }
}
else
{
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 9a8b8cf665..3e19ef47e2 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
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: CDOSyntheticIdPropertyHandler.java,v 1.4 2008-06-15 20:32:15 mtaal Exp $
+ * $Id: CDOSyntheticIdPropertyHandler.java,v 1.5 2008-06-15 20:47:36 mtaal Exp $
*/
package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
@@ -41,7 +41,7 @@ import java.util.Map;
* Is only used for synthetic id's.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
@SuppressWarnings("unchecked")
public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAccessor
@@ -102,7 +102,11 @@ public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAc
return;
}
- final HibernateCommitContext hcc = HibernateThreadContext.getHibernateCommitContext();
+ HibernateCommitContext hcc = null;
+ if (HibernateThreadContext.isHibernateCommitContextSet())
+ {
+ hcc = HibernateThreadContext.getHibernateCommitContext();
+ }
InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(target);
CDOID cdoID = revision.getID();
@@ -111,15 +115,21 @@ public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAc
CDOIDHibernate newCDOID = CDOIDHibernateFactoryImpl.getInstance().createCDOID((Serializable)value,
revision.getCDOClass().getName());
revision.setID(newCDOID);
- hcc.setNewID(cdoID, newCDOID);
+ if (hcc != null)
+ {
+ hcc.setNewID(cdoID, newCDOID);
+ }
}
else if (cdoID instanceof CDOIDTemp)
{
CDOIDHibernate newCDOID = CDOIDHibernateFactoryImpl.getInstance().createCDOID((Serializable)value,
revision.getCDOClass().getName());
revision.setID(newCDOID);
- hcc.getCommitContext().addIDMapping((CDOIDTemp)cdoID, newCDOID);
- hcc.setNewID(cdoID, newCDOID);
+ if (hcc != null)
+ {
+ hcc.getCommitContext().addIDMapping((CDOIDTemp)cdoID, newCDOID);
+ hcc.setNewID(cdoID, newCDOID);
+ }
}
else
{

Back to the top