Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreAccessor.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreChunkReader.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreReader.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreWriter.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateFileMappingProvider.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java428
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java299
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java120
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreChunkReader.java55
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreFactory.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreReader.java160
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreWriter.java193
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java148
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/bundle/OM.java44
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ClassServerInfo.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/FeatureServerInfo.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/PackageServerInfo.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ServerInfo.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java131
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java61
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java180
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java37
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java42
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyGetter.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java51
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionInstantiator.java61
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionLazyInitializer.java42
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionPropertyAccessor.java155
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java302
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxyFactory.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java293
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java143
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticVersionPropertyHandler.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java118
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java49
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java325
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java111
48 files changed, 0 insertions, 4739 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
deleted file mode 100644
index 1545af13c9..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - added mappingProvider support
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
-
-/**
- * @author Eike Stepper
- * @author Martin Taal
- */
-public final class CDOHibernateUtil
-{
- private CDOHibernateUtil()
- {
- }
-
- public static IHibernateStore createStore(IHibernateMappingProvider mappingProvider)
- {
- return new HibernateStore(mappingProvider);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java
deleted file mode 100644
index 2b1ec7df41..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.hibernate.cfg.Configuration;
-
-/**
- * A mappingprovider adds a hibernate mapping to a hibernate configuration object.
- *
- * @author Martin Taal
- */
-public interface IHibernateMappingProvider
-{
- /** Adds a mapping to a configuration object */
- public void addMapping(Configuration configuration);
-
- /** Sets the Store in the mapping provider, is called before addMapping. */
- public void setHibernateStore(IHibernateStore hibernateStore);
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java
deleted file mode 100644
index 3f270d650b..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernatePackageHandler;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-
-/**
- * @author Eike Stepper
- */
-public interface IHibernateStore extends IStore
-{
- public Configuration getHibernateConfiguration();
-
- public SessionFactory getHibernateSessionFactory();
-
- public IHibernateStoreReader getReader(ISession session);
-
- public IHibernateStoreWriter getWriter(IView view);
-
- public HibernatePackageHandler getPackageHandler();
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreAccessor.java
deleted file mode 100644
index a506b6e5b0..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreAccessor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.eclipse.emf.cdo.server.IStoreAccessor;
-
-import org.hibernate.Session;
-
-/**
- * @author Eike Stepper
- */
-public interface IHibernateStoreAccessor extends IStoreAccessor
-{
- public IHibernateStore getStore();
-
- public Session getHibernateSession();
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreChunkReader.java
deleted file mode 100644
index dc36a94e53..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreChunkReader.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.eclipse.emf.cdo.server.IStoreChunkReader;
-
-/**
- * @author Eike Stepper
- */
-public interface IHibernateStoreChunkReader extends IStoreChunkReader
-{
- public IHibernateStoreReader getStoreReader();
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreReader.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreReader.java
deleted file mode 100644
index 8eda1d407b..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreReader.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreReader;
-
-/**
- * @author Eike Stepper
- */
-public interface IHibernateStoreReader extends IHibernateStoreAccessor, IStoreReader
-{
- public IHibernateStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature);
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreWriter.java
deleted file mode 100644
index 5ebd9fac01..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStoreWriter.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.hibernate;
-
-import org.eclipse.emf.cdo.server.IStoreWriter;
-
-/**
- * @author Eike Stepper
- */
-public interface IHibernateStoreWriter extends IHibernateStoreReader, IStoreWriter
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java
deleted file mode 100644
index 41b0fd45c7..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreWriter.CommitContext;
-
-import java.util.HashMap;
-
-/**
- * A HibernateCommitContext contains the commitcontext as well as support for direct (hashmap) based search for a new or
- * changed object using the id.
- *
- * @author Martin Taal
- */
-public class HibernateCommitContext
-{
- private CommitContext commitContext;
-
- private HashMap<CDOID, CDORevision> dirtyObjects = null;
-
- private HashMap<CDOID, CDORevision> newObjects = null;
-
- public CommitContext getCommitContext()
- {
- return commitContext;
- }
-
- public void setCommitContext(CommitContext commitContext)
- {
- this.commitContext = commitContext;
- }
-
- // initialize is not done when the commitContext is set because it appeared
- // that at that moment the temp id's are not repaired. The initialize method
- // is called on demand.
- protected void initialize()
- {
- if (dirtyObjects != null)
- {
- return;
- }
-
- dirtyObjects = new HashMap<CDOID, CDORevision>();
- for (CDORevision cdoRevision : commitContext.getDirtyObjects())
- {
- dirtyObjects.put(cdoRevision.getID(), cdoRevision);
- }
-
- newObjects = new HashMap<CDOID, CDORevision>();
- for (CDORevision cdoRevision : commitContext.getNewObjects())
- {
- newObjects.put(cdoRevision.getID(), cdoRevision);
- }
- }
-
- public CDORevision getDirtyObject(CDOID id)
- {
- initialize();
- return dirtyObjects.get(id);
- }
-
- public CDORevision getNewObject(CDOID id)
- {
- initialize();
- return newObjects.get(id);
- }
-
- public void setNewID(CDOID oldId, CDOID newId)
- {
- initialize();
- CDORevision cdoRevision;
- if ((cdoRevision = dirtyObjects.get(oldId)) != null)
- {
- dirtyObjects.remove(oldId);
- dirtyObjects.put(newId, cdoRevision);
- return;
- }
-
- if ((cdoRevision = newObjects.get(oldId)) != null)
- {
- newObjects.remove(oldId);
- newObjects.put(newId, cdoRevision);
- return;
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateFileMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateFileMappingProvider.java
deleted file mode 100644
index f1853b3b0f..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateFileMappingProvider.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Springsite B.V. and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStore;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.cfg.Configuration;
-
-import java.io.InputStream;
-
-/**
- * Reads the hibernate mapping file from one or more resource locations and adds them to the configuration.
- *
- * @author Martin Taal
- */
-public class HibernateFileMappingProvider implements IHibernateMappingProvider
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateFileMappingProvider.class);
-
- private IHibernateStore hibernateStore;
-
- private final String[] mappingFileLocations;
-
- public HibernateFileMappingProvider(String location)
- {
- this(new String[] { location });
- }
-
- public HibernateFileMappingProvider(String[] locations)
- {
- mappingFileLocations = locations;
- }
-
- public IHibernateStore getHibernateStore()
- {
- return hibernateStore;
- }
-
- public void setHibernateStore(IHibernateStore hibernateStore)
- {
- this.hibernateStore = hibernateStore;
- }
-
- public void addMapping(Configuration configuration)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Adding hibernate mapping from location(s):");
- }
-
- for (String location : mappingFileLocations)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace(location);
- }
-
- InputStream is = null;
- try
- {
- // MT.Question: the mapping file is in a dependent plugin but when using the OM.BUNDLE
- // it tries to find it in this plugin and I get:
- // filenotfound:
- // /home/mtaal/mydata/dev/workspaces/nextspace/org.eclipse.emf.cdo.server.hibernate/mappings/product.hbm.xml
- // I have set Eclipse-BuddyPolicy to dependent
- // is = OM.BUNDLE.getInputStream(location);
- is = getClass().getResourceAsStream(location);
- configuration.addInputStream(is);
- }
- catch (Exception e)
- {
- throw WrappedException.wrap(e);
- }
- finally
- {
- IOUtil.close(is);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
deleted file mode 100644
index b3f5b8a031..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - moved code from HibernateStore to this class
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.model.CDOClass;
-import org.eclipse.emf.cdo.common.model.CDOClassProxy;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.server.IStoreWriter.CommitContext;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.InternalCDOClass;
-import org.eclipse.emf.cdo.spi.common.InternalCDOFeature;
-import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.criterion.Expression;
-import org.hibernate.tool.hbm2ddl.SchemaUpdate;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Delegate which stores and retrieves cdo packages.
- * <p>
- * TODO extend {@link Lifecycle}. See {@link #doActivate()} and {@link #doDeactivate()}.
- *
- * @author Eike Stepper
- * @author Martin Taal
- */
-public class HibernatePackageHandler extends Lifecycle
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateStoreWriter.class);
-
- private Configuration configuration;
-
- private SessionFactory sessionFactory;
-
- private int nextPackageID;
-
- private int nextClassID;
-
- private int nextFeatureID;
-
- private Collection<CDOPackageInfo> cdoPackageInfos = null;
-
- private HibernateStore hibernateStore;
-
- /**
- * TODO Necessary to pass/store/dump the properties from the store?
- */
- public HibernatePackageHandler(HibernateStore store)
- {
- hibernateStore = store;
- }
-
- public List<CDOPackage> getCDOPackages()
- {
- List<CDOPackage> cdoPackages = new ArrayList<CDOPackage>();
- if (HibernateThreadContext.isHibernateCommitContextSet())
- {
- CommitContext cc = HibernateThreadContext.getHibernateCommitContext().getCommitContext();
- if (cc instanceof org.eclipse.emf.cdo.internal.server.Transaction)
- {
- org.eclipse.emf.cdo.internal.server.Transaction tx = (org.eclipse.emf.cdo.internal.server.Transaction)cc;
- for (CDOPackage cdoPackage : tx.getNewPackages())
- {
- cdoPackages.add(cdoPackage);
- }
- }
- }
-
- for (CDOPackage cdoPackage : hibernateStore.getRepository().getPackageManager().getPackages())
- {
- cdoPackages.add(cdoPackage);
- }
-
- for (CDOPackage cdoPackage : cdoPackages)
- {
- // force resolve
- if (cdoPackage.getClassCount() == 0)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Returning " + cdoPackage.getPackageURI());
- }
- }
- }
-
- return cdoPackages;
- }
-
- public void writePackages(CDOPackage... cdoPackages)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Persisting new CDOPackages");
- }
-
- Session session = getSessionFactory().openSession();
- Transaction tx = session.beginTransaction();
- boolean err = true;
- boolean updated = false;
-
- try
- {
- for (CDOPackage cdoPackage : cdoPackages)
- {
- if (cdoPackageExistsAndIsUnchanged(cdoPackage))
- {
- OM.LOG.warn("CDOPackage " + cdoPackage.getPackageURI() + " already exists not persisting it again!");
- continue;
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Persisting CDOPackage " + cdoPackage.getPackageURI());
- }
-
- session.saveOrUpdate(cdoPackage);
- updated = true;
- }
-
- tx.commit();
- err = false;
- }
- finally
- {
- if (err)
- {
- tx.rollback();
- }
-
- session.close();
- }
-
- if (updated)
- {
- reset();
- hibernateStore.reInitialize();
- }
- }
-
- protected boolean cdoPackageExistsAndIsUnchanged(CDOPackage newCDOPackage)
- {
- CDOPackage[] cdoPackages = hibernateStore.getRepository().getPackageManager().getPackages();
- for (CDOPackage cdoPackage : cdoPackages)
- {
- if (cdoPackage.getClassCount() > 0 && cdoPackage.getPackageURI().compareTo(newCDOPackage.getPackageURI()) == 0)
- {
- return cdoPackage.getEcore().compareTo(newCDOPackage.getEcore()) == 0;
- }
- }
-
- return false;
- }
-
- public void writePackage(CDOPackage cdoPackage)
- {
- if (cdoPackageExistsAndIsUnchanged(cdoPackage))
- {
- OM.LOG.warn("CDOPackage " + cdoPackage.getPackageURI() + " already exists not persisting it again!");
- return;
- }
-
- Session session = getSessionFactory().openSession();
- Transaction tx = session.beginTransaction();
- boolean err = true;
- try
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Persisting CDOPackage " + cdoPackage.getPackageURI());
- }
-
- session.saveOrUpdate(cdoPackage);
- tx.commit();
- err = false;
- }
- finally
- {
- if (err)
- {
- tx.rollback();
- }
-
- session.close();
- }
-
- reset();
- hibernateStore.reInitialize();
- }
-
- public Collection<CDOPackageInfo> getCDOPackageInfos()
- {
- readPackageInfos();
- return cdoPackageInfos;
- }
-
- protected void readPackage(CDOPackage cdoPackage)
- {
- if (cdoPackage.getClassCount() > 0)
- { // already initialized go away
- return;
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Reading CDOPackage with uri " + cdoPackage.getPackageURI() + " from db");
- }
-
- Session session = getSessionFactory().openSession();
-
- try
- {
- Criteria criteria = session.createCriteria(CDOPackage.class);
- criteria.add(Expression.eq("packageURI", cdoPackage.getPackageURI()));
- List<?> list = criteria.list();
- if (list.size() != 1)
- {
- throw new IllegalArgumentException("CDOPackage with uri " + cdoPackage.getPackageURI()
- + " not present in the db");
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Found " + list.size() + " CDOPackages in DB");
- }
-
- CDOPackage dbPackage = (CDOPackage)list.get(0);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Read CDOPackage: " + cdoPackage.getName());
- }
-
- ((InternalCDOPackage)cdoPackage).setServerInfo(dbPackage.getServerInfo());
- ((InternalCDOPackage)cdoPackage).setName(dbPackage.getName());
- ((InternalCDOPackage)cdoPackage).setEcore(dbPackage.getEcore());
- ((InternalCDOPackage)cdoPackage).setMetaIDRange(cdoPackage.getMetaIDRange());
-
- final List<CDOClass> cdoClasses = new ArrayList<CDOClass>();
- for (CDOClass cdoClass : dbPackage.getClasses())
- {
- cdoClasses.add(cdoClass);
- for (CDOClassProxy proxy : ((InternalCDOClass)cdoClass).getSuperTypeProxies())
- {
- proxy.setCDOPackageManager(hibernateStore.getRepository().getPackageManager());
- }
-
- for (CDOFeature cdoFeature : cdoClass.getFeatures())
- {
- final InternalCDOFeature internalFeature = (InternalCDOFeature)cdoFeature;
- internalFeature.setContainingClass(cdoClass);
- if (internalFeature.getReferenceTypeProxy() != null)
- {
- internalFeature.getReferenceTypeProxy().setCDOPackageManager(
- hibernateStore.getRepository().getPackageManager());
- }
- }
- }
-
- ((InternalCDOPackage)cdoPackage).setClasses(cdoClasses);
- }
- finally
- {
- session.close();
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Finished reading CDOPackages");
- }
- }
-
- protected void readPackageInfos()
- {
- if (cdoPackageInfos == null || cdoPackageInfos.size() == 0)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Reading CDOPackages from db");
- }
-
- Collection<CDOPackageInfo> result = new ArrayList<CDOPackageInfo>();
- Session session = getSessionFactory().openSession();
-
- try
- {
- Criteria criteria = session.createCriteria(CDOPackage.class);
- List<?> list = criteria.list();
- if (TRACER.isEnabled())
- {
- TRACER.trace("Found " + list.size() + " CDOPackages in DB");
- }
-
- for (Object object : list)
- {
- CDOPackage cdoPackage = (CDOPackage)object;
- if (TRACER.isEnabled())
- {
- TRACER.trace("Read CDOPackage: " + cdoPackage.getName());
- }
-
- result.add(new CDOPackageInfo(cdoPackage.getPackageURI(), cdoPackage.isDynamic(),
- cdoPackage.getMetaIDRange(), cdoPackage.getParentURI()));
- ((InternalCDOPackage)cdoPackage).setPackageManager(hibernateStore.getRepository().getPackageManager());
- }
-
- cdoPackageInfos = result;
- }
- finally
- {
- session.close();
- }
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Finished reading CDOPackages");
- }
- }
-
- public synchronized SessionFactory getSessionFactory()
- {
- if (sessionFactory == null)
- {
- sessionFactory = configuration.buildSessionFactory();
- }
-
- return sessionFactory;
- }
-
- public synchronized int getNextPackageID()
- {
- return nextPackageID++;
- }
-
- public synchronized int getNextClassID()
- {
- return nextClassID++;
- }
-
- public synchronized int getNextFeatureID()
- {
- return nextFeatureID++;
- }
-
- public void reset()
- {
- cdoPackageInfos = null;
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- initConfiguration();
- initSchema();
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- if (sessionFactory != null)
- {
- sessionFactory.close();
- sessionFactory = null;
- }
-
- super.doDeactivate();
- }
-
- protected void initConfiguration()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Initializing configuration for CDO metadata");
- }
-
- InputStream in = null;
-
- try
- {
- in = OM.BUNDLE.getInputStream("mappings/meta.hbm.xml");
- configuration = new Configuration();
- configuration.addInputStream(in);
- configuration.setProperties(HibernateUtil.getInstance().getPropertiesFromStore(hibernateStore));
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- IOUtil.close(in);
- }
- }
-
- protected void initSchema()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Updating db schema for Hibernate PackageHandler");
- }
-
- new SchemaUpdate(configuration).execute(true, true);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java
deleted file mode 100644
index 23d49b4bb0..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - moved cdopackage handler to other class, changed configuration
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.id.CDOIDLibraryDescriptor;
-import org.eclipse.emf.cdo.common.id.CDOIDLibraryProvider;
-import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
-import org.eclipse.emf.cdo.internal.server.Store;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStore;
-import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateFactoryImpl;
-import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateLibraryHandler;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOInterceptor;
-import org.eclipse.emf.cdo.spi.common.CDOIDLibraryProviderImpl;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-
-import java.io.InputStream;
-
-/**
- * @author Eike Stepper
- * @author Martin Taal
- */
-public class HibernateStore extends Store implements IHibernateStore
-{
- public static final String TYPE = "hibernate";
-
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateStore.class);
-
- private static final CDOIDObjectFactory CDOID_OBJECT_FACTORY = new CDOIDHibernateFactoryImpl();
-
- private static final IDLibraryProvider CDOID_LIBRARY_PROVIDER = new IDLibraryProvider();
-
- private static final CDOIDLibraryDescriptor CDOID_LIBRARY_DESCRIPTOR = CDOID_LIBRARY_PROVIDER
- .createDescriptor(CDOIDHibernateFactoryImpl.class.getName());
-
- /**
- * Used to give different extensions of Hibernate a context when initializing
- */
- private static ThreadLocal<HibernateStore> currentHibernateStore = new ThreadLocal<HibernateStore>();
-
- private Configuration hibernateConfiguration;
-
- private SessionFactory hibernateSessionFactory;
-
- private HibernatePackageHandler packageHandler;
-
- private IHibernateMappingProvider mappingProvider;
-
- public HibernateStore(IHibernateMappingProvider mappingProvider)
- {
- super(TYPE);
- this.mappingProvider = mappingProvider;
- packageHandler = new HibernatePackageHandler(this);
-
- if (TRACER.isEnabled() && mappingProvider != null)
- {
- TRACER.trace("HibernateStore with mappingProvider " + mappingProvider.getClass().getName());
- }
- }
-
- public Configuration getHibernateConfiguration()
- {
- return hibernateConfiguration;
- }
-
- public synchronized SessionFactory getHibernateSessionFactory()
- {
- if (hibernateSessionFactory == null)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Initializing SessionFactory for HibernateStore");
- }
-
- currentHibernateStore.set(this);
-
- try
- {
- initConfiguration();
- hibernateSessionFactory = hibernateConfiguration.buildSessionFactory();
- }
- finally
- {
- currentHibernateStore.set(null);
- }
- }
-
- return hibernateSessionFactory;
- }
-
- public boolean hasAuditingSupport()
- {
- return false;
- }
-
- public boolean hasBranchingSupport()
- {
- return false;
- }
-
- public boolean hasWriteDeltaSupport()
- {
- return false;
- }
-
- public CDOIDObjectFactory getCDOIDObjectFactory()
- {
- return CDOID_OBJECT_FACTORY;
- }
-
- public CDOIDLibraryDescriptor getCDOIDLibraryDescriptor()
- {
- return CDOID_LIBRARY_DESCRIPTOR;
- }
-
- public CDOIDLibraryProvider getCDOIDLibraryProvider()
- {
- return CDOID_LIBRARY_PROVIDER;
- }
-
- @Override
- public HibernateStoreReader getReader(ISession session)
- {
- return (HibernateStoreReader)super.getReader(session);
- }
-
- @Override
- public HibernateStoreReader createReader(ISession session)
- {
- return new HibernateStoreReader(this, session);
- }
-
- @Override
- public HibernateStoreWriter getWriter(IView view)
- {
- return (HibernateStoreWriter)super.getWriter(view);
- }
-
- @Override
- public HibernateStoreWriter createWriter(IView view)
- {
- return new HibernateStoreWriter(this, view);
- }
-
- public synchronized int getNextPackageID()
- {
- return packageHandler.getNextPackageID();
- }
-
- public synchronized int getNextClassID()
- {
- return packageHandler.getNextClassID();
- }
-
- public synchronized int getNextFeatureID()
- {
- return packageHandler.getNextFeatureID();
- }
-
- public boolean wasCrashed()
- {
- return false;
- }
-
- public void repairAfterCrash()
- {
- throw new UnsupportedOperationException(); // TODO Implement me
- }
-
- public HibernatePackageHandler getPackageHandler()
- {
- return packageHandler;
- }
-
- // TODO: synchronize??
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- packageHandler.activate();
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- if (hibernateSessionFactory != null)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Closing SessionFactory");
- }
-
- hibernateSessionFactory.close();
- hibernateSessionFactory = null;
- }
-
- packageHandler.deactivate();
- super.doDeactivate();
- }
-
- // is called after a new package has been added
- // TODO: synchronize??
- // TODO: combine with doActivate/doDeactivate??
- // TODO: assumes that packageHandler has been reset
- protected void reInitialize()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Re-Initializing HibernateStore");
- }
-
- if (hibernateSessionFactory != null)
- {
- if (!hibernateSessionFactory.isClosed())
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Closing SessionFactory");
- }
-
- hibernateSessionFactory.close();
- }
-
- hibernateSessionFactory = null;
- }
- }
-
- protected void initConfiguration()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Initializing Configuration");
- }
-
- InputStream in = null;
-
- try
- {
- hibernateConfiguration = new Configuration();
- if (mappingProvider != null)
- {
- mappingProvider.setHibernateStore(this);
- mappingProvider.addMapping(hibernateConfiguration);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Adding resource.hbm.xml to configuration");
- }
-
- in = OM.BUNDLE.getInputStream("mappings/resource.hbm.xml");
- hibernateConfiguration.addInputStream(in);
- hibernateConfiguration.setInterceptor(new CDOInterceptor());
- hibernateConfiguration.setProperties(HibernateUtil.getInstance().getPropertiesFromStore(this));
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- IOUtil.close(in);
- }
- }
-
- public static HibernateStore getCurrentHibernateStore()
- {
- return currentHibernateStore.get();
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class IDLibraryProvider extends CDOIDLibraryProviderImpl
- {
- public IDLibraryProvider()
- {
- addLibrary(CDOIDHibernateLibraryHandler.LIBRARY_NAME, org.eclipse.emf.cdo.server.hibernate.internal.id.bundle.OM.BUNDLE);
- }
- }
-}
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
deleted file mode 100644
index e01d838c31..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - specific hibernate functionality
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.internal.server.StoreAccessor;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStoreAccessor;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-
-/**
- * @author Eike Stepper
- * @author Martin Taal
- */
-public class HibernateStoreAccessor extends StoreAccessor implements IHibernateStoreAccessor
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateStoreAccessor.class);
-
- private Session hibernateSession;
-
- protected HibernateStoreAccessor(HibernateStore store, ISession session)
- {
- super(store, session);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
- }
- }
-
- protected HibernateStoreAccessor(HibernateStore store, IView view)
- {
- super(store, view);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
- }
- }
-
- protected Session createHibernateSession()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Creating hibernate session and setting it in threadlocal HibernateThreadContext");
- }
-
- SessionFactory sessionFactory = getStore().getHibernateSessionFactory();
- Session session = sessionFactory.openSession();
- HibernateThreadContext.setSession(session);
- return session;
- }
-
- @Override
- protected void doRelease()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Releasing hibernate session");
- }
-
- HibernateThreadContext.setSession(null);
- clearHibernateSession();
- }
-
- /** Clears the current hibernate session and sets a new one in the thread context */
- public void resetHibernateSession()
- {
- clearHibernateSession();
- getHibernateSession();
- }
-
- @Override
- public HibernateStore getStore()
- {
- return (HibernateStore)super.getStore();
- }
-
- public void clearHibernateSession()
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Removing hibernate session");
- }
-
- if (hibernateSession != null && hibernateSession.isOpen())
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Closing hibernate session");
- }
-
- hibernateSession.close();
- }
-
- hibernateSession = null;
- }
-
- public Session getHibernateSession()
- {
- if (hibernateSession == null)
- {
- hibernateSession = createHibernateSession();
- }
-
- return hibernateSession;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreChunkReader.java
deleted file mode 100644
index 5c99c483c1..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreChunkReader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.internal.server.StoreChunkReader;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStoreChunkReader;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStoreReader;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class HibernateStoreChunkReader extends StoreChunkReader implements IHibernateStoreChunkReader
-{
- public HibernateStoreChunkReader(IHibernateStoreReader storeReader, CDORevision revision, CDOFeature feature)
- {
- super(storeReader, revision, feature);
- }
-
- @Override
- public HibernateStoreReader getStoreReader()
- {
- return (HibernateStoreReader)super.getStoreReader();
- }
-
- @Override
- public void addSimpleChunk(int index)
- {
- // super.addSimpleChunk(index);
- throw new UnsupportedOperationException(); // TODO Implement me
- }
-
- @Override
- public void addRangedChunk(int fromIndex, int toIndex)
- {
- // super.addRangedChunk(fromIndex, toIndex);
- throw new UnsupportedOperationException(); // TODO Implement me
- }
-
- public List<Chunk> executeRead()
- {
- throw new UnsupportedOperationException(); // TODO Implement me
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreFactory.java
deleted file mode 100644
index 6cda2111c7..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.IStoreFactory;
-
-import org.w3c.dom.Element;
-
-/**
- * @author Eike Stepper
- */
-public class HibernateStoreFactory implements IStoreFactory
-{
- public HibernateStoreFactory()
- {
- }
-
- public String getStoreType()
- {
- return HibernateStore.TYPE;
- }
-
- public IStore createStore(Element storeConfig)
- {
- throw new UnsupportedOperationException(); // TODO Implement me
- // IMappingStrategy mappingStrategy = getMappingStrategy(storeConfig);
- // IDBAdapter dbAdapter = getDBAdapter(storeConfig);
- // DataSource dataSource = getDataSource(storeConfig);
- // IDBConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
- // HibernateStore store = new HibernateStore(mappingStrategy, dbAdapter, connectionProvider);
- // mappingStrategy.setStore(store);
- // return store;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreReader.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreReader.java
deleted file mode 100644
index 2424eaf0cb..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreReader.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - specific hibernate functionality
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOClassRef;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStoreReader;
-import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-
-import org.eclipse.net4j.util.collection.CloseableIterator;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.Criteria;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.criterion.Expression;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @author Martin Taal
- */
-public class HibernateStoreReader extends HibernateStoreAccessor implements IHibernateStoreReader
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateStoreReader.class);
-
- public HibernateStoreReader(HibernateStore store, ISession session)
- {
- super(store, session);
- }
-
- protected HibernateStoreReader(HibernateStore store, IView view)
- {
- super(store, view);
- }
-
- public HibernateStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature)
- {
- return new HibernateStoreChunkReader(this, revision, feature);
- }
-
- public CloseableIterator<CDOID> readObjectIDs(boolean withTypes)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOClassRef readObjectType(CDOID id)
- {
- CDORevision cdoRevision = readRevision(id, -1);
- return cdoRevision.getCDOClass().createClassRef();
- }
-
- public void readPackage(CDOPackage cdoPackage)
- {
- getStore().getPackageHandler().readPackage(cdoPackage);
- }
-
- public Collection<CDOPackageInfo> readPackageInfos()
- {
- return getStore().getPackageHandler().getCDOPackageInfos();
- }
-
- public CDOID readResourceID(String path)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Finding resourceid using path " + path);
- }
-
- Session session = getHibernateSession();
- Criteria criteria = session.createCriteria(CDOResourceClass.NAME);
- criteria.add(Expression.eq("path", path));
- List<?> result = criteria.list();
- if (result.size() == 0)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Resource not found");
- }
-
- // TODO: throw exception?
- return null;
- }
-
- // TODO: throw exception if list.size() > 1?
- CDORevision cdoRevision = (CDORevision)result.get(0);
- return cdoRevision.getID();
- }
-
- public String readResourcePath(CDOID id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException("ID must be not null");
- }
-
- if (!(id instanceof CDOIDHibernate))
- {
- throw new IllegalArgumentException("ID type " + id.getClass().getName() + " not supported by hibernate reader");
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Finding resource using id " + id);
- }
-
- Session session = getHibernateSession();
- Query qry = session.createQuery("select path from " + CDOResourceClass.NAME + " where id=:id");
- CDOIDHibernate idHibernate = (CDOIDHibernate)id;
- qry.setParameter("id", idHibernate.getId());
- final List<?> result = qry.list();
- if (result.size() == 0)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Resource not found");
- }
-
- // TODO: throw exception?
- return null;
- }
-
- return (String)result.get(0);
- }
-
- public CDORevision readRevision(CDOID id, int referenceChunk)
- {
- return HibernateUtil.getInstance().getCDORevision(id);
- }
-
- public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
- {
- // TODO Could be necessary to implement
- throw new UnsupportedOperationException();
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreWriter.java
deleted file mode 100644
index e8b84118a6..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreWriter.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - added hibernate specific implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.model.CDOClassProxy;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.hibernate.IHibernateStoreWriter;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.InternalCDOClass;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.FlushMode;
-import org.hibernate.Session;
-
-/**
- * @author Eike Stepper
- */
-public class HibernateStoreWriter extends HibernateStoreReader implements IHibernateStoreWriter
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateStoreWriter.class);
-
- public HibernateStoreWriter(HibernateStore store, IView view)
- {
- super(store, view);
- }
-
- @Override
- public void commit(CommitContext context)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Committing transaction");
- }
-
- HibernateThreadContext.setCommitContext(context);
- writePackages(context.getNewPackages());
-
- try
- {
- // start with fresh hibernate session
- Session session = getHibernateSession();
- session.setFlushMode(FlushMode.COMMIT);
- session.beginTransaction();
- for (Object o : context.getNewObjects())
- {
- CDORevision cdoRevision = (CDORevision)o;
- session.save(HibernateUtil.getInstance().getEntityName(cdoRevision), o);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Persisted new Object " + ((CDORevision)o).getCDOClass().getName() + " id: "
- + cdoRevision.getID());
- }
- }
-
- for (Object o : context.getDirtyObjects())
- {
- try
- {
- CDORevision cdoRevision = (CDORevision)o;
- if (cdoRevision instanceof InternalCDORevision)
- {
- ((InternalCDORevision)cdoRevision).setVersion(cdoRevision.getVersion() - 1);
- }
-
- session.update(HibernateUtil.getInstance().getEntityName(cdoRevision), o);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Updated Object " + ((CDORevision)o).getCDOClass().getName() + " id: " + cdoRevision.getID());
- }
- }
- catch (Exception e)
- {
- OM.LOG.error(e);
- throw WrappedException.wrap(e);
- }
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Commit hibernate transaction");
- }
-
- session.getTransaction().commit();
- }
- finally
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Clearing used hibernate session");
- }
-
- HibernateThreadContext.setCommitContext(null);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Applying id mappings");
- }
-
- context.applyIDMappings();
- }
-
- @Override
- public boolean isReader()
- {
- // TODO Is this necessary?
- return false;
- }
-
- @Override
- public void rollback(CommitContext context)
- {
- // Don't do anything as the real action is done at commit (which does not happen now)
- if (TRACER.isEnabled())
- {
- TRACER.trace("Rollbacked called");
- }
- }
-
- @Override
- protected void writeClass(InternalCDOClass cdoClass)
- {
- throw new UnsupportedOperationException("Should not be called, should be handled by hibernate cascade");
- }
-
- @Override
- protected void writeFeature(CDOFeature feature)
- {
- throw new UnsupportedOperationException("Should not be called, should be handled by hibernate cascade");
- }
-
- @Override
- protected void writePackages(CDOPackage... cdoPackages)
- {
- if (cdoPackages != null && cdoPackages.length != 0)
- {
- getStore().getPackageHandler().writePackages(cdoPackages);
- }
-
- // Set a new hibernatesession in the thread
- resetHibernateSession();
- }
-
- @Override
- protected void writePackage(CDOPackage cdoPackage)
- {
- throw new UnsupportedOperationException("Should not be called");
- }
-
- @Override
- protected void writeRevision(CDORevision revision)
- {
- // Do nothing, do it all at commit
- }
-
- @Override
- protected void writeRevisionDelta(CDORevisionDelta revisionDelta)
- {
- }
-
- @Override
- protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas)
- {
- }
-
- @Override
- protected void writeRevisions(CDORevision[] revisions)
- {
- // Don't do anything it is done at commit
- }
-
- @Override
- protected void writeSuperType(InternalCDOClass type, CDOClassProxy superType)
- {
- throw new UnsupportedOperationException("Should not be called, should be handled by hibernate cascade");
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java
deleted file mode 100644
index 9cca7a24ef..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.server.IStoreWriter.CommitContext;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.Session;
-
-/**
- * @author Martin Taal
- */
-public class HibernateThreadContext
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HibernateThreadContext.class);
-
- private static ThreadLocal<HibernateCommitContext> commitContext = new ThreadLocal<HibernateCommitContext>();
-
- private static ThreadLocal<Session> session = new ThreadLocal<Session>();
-
- public static Session getSession()
- {
- Session result = session.get();
- if (result == null)
- {
- throw new IllegalStateException("Session not set");
- }
-
- return result;
- }
-
- public static void setSession(Session newSession)
- {
- if (newSession != null && session.get() != null)
- {
- throw new IllegalStateException("Session already set");
- }
-
- if (TRACER.isEnabled())
- {
- if (newSession == null)
- {
- TRACER.trace("Clearing session in threadlocal");
- }
- else
- {
- TRACER.trace("Setting session in threadlocal");
- }
- }
-
- session.set(newSession);
- }
-
- public static HibernateCommitContext getHibernateCommitContext()
- {
- HibernateCommitContext result = commitContext.get();
- if (result == null)
- {
- throw new IllegalStateException("CommitContext not set");
- }
-
- return result;
- }
-
- public static boolean isHibernateCommitContextSet()
- {
- return commitContext.get() != null;
- }
-
- public static void setCommitContext(CommitContext newCommitContext)
- {
- if (newCommitContext != null && commitContext.get() != null)
- {
- throw new IllegalStateException("CommitContext already set");
- }
-
- if (TRACER.isEnabled())
- {
- if (newCommitContext == null)
- {
- TRACER.trace("Clearing commitcontext in threadlocal");
- }
- else
- {
- TRACER.trace("Setting commitcontext in threadlocal");
- }
- }
-
- // reset the context
- if (newCommitContext == null)
- {
- commitContext.set(null);
- }
- else
- {
- final HibernateCommitContext hcc = new HibernateCommitContext();
- hcc.setCommitContext(newCommitContext);
- commitContext.set(hcc);
- }
- }
-}
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
deleted file mode 100644
index 37d5de5b41..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.Session;
-
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @author Martin Taal
- */
-public class HibernateUtil
-{
- private static HibernateUtil instance = new HibernateUtil();
-
- /**
- * @return the instance
- */
- public static HibernateUtil getInstance()
- {
- return instance;
- }
-
- /**
- * @param instance
- * the instance to set
- */
- public static void setInstance(HibernateUtil instance)
- {
- HibernateUtil.instance = instance;
- }
-
- /** Converts from a Map<String, String> to a Properties */
- public Properties getPropertiesFromStore(IStore store)
- {
- Properties props = new Properties();
- Map<String, String> storeProps = store.getRepository().getProperties();
- for (String key : storeProps.keySet())
- {
- props.setProperty(key, storeProps.get(key));
- }
-
- return props;
- }
-
- public String getEntityName(CDORevision cdoRevision)
- {
- return cdoRevision.getCDOClass().getName();
- }
-
- /**
- * Translates a temporary cdoID into a hibernate ID, by finding the object it refers to in the CommitContext and then
- * returning or by persisting the object. Note assumes that the hibernate session and CommitContext are set in
- * HibernateThreadContext.
- */
- public CDOIDHibernate getCDOIDHibernate(CDOID cdoID)
- {
- CDORevision cdoRevision = getCDORevision(cdoID);
- if (cdoRevision.getID() instanceof CDOIDHibernate)
- {
- return (CDOIDHibernate)cdoRevision.getID();
- }
-
- Session session = HibernateThreadContext.getSession();
- session.saveOrUpdate(cdoRevision);
- if (!(cdoRevision.getID() instanceof CDOIDHibernate))
- {
- throw new IllegalStateException("CDORevision " + cdoRevision.getCDOClass().getName() + " " + cdoRevision.getID()
- + " does not have a hibernate cdoid after saving/updating it");
- }
-
- return (CDOIDHibernate)cdoRevision.getID();
- }
-
- public InternalCDORevision getCDORevision(Object target)
- {
- // if (target instanceof CDOObject)
- // {
- // return (InternalCDORevision)((CDOObject)target).cdoRevision();
- // }
- // else
- // {
- return (InternalCDORevision)target;
- // }
- }
-
- /**
- * Gets a current object, first checks the new and dirty objects from the commitcontent. Otherwise reads it from the
- * session.
- */
- public CDORevision getCDORevision(CDOID id)
- {
- if (id.isNull())
- {
- return null;
- }
-
- if (HibernateThreadContext.isHibernateCommitContextSet())
- {
- 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)
- {
- return getCDORevision(newID);
- }
- }
- }
-
- if (!(id instanceof CDOIDHibernate))
- {
- throw new IllegalArgumentException("Passed cdoid is not an instance of CDOIDHibernate but a "
- + id.getClass().getName() + ": " + id);
- }
-
- CDOIDHibernate cdoIDHibernate = (CDOIDHibernate)id;
- Session session = HibernateThreadContext.getSession();
- return (CDORevision)session.get(cdoIDHibernate.getEntityName(), cdoIDHibernate.getId());
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/bundle/OM.java
deleted file mode 100644
index eed970eb48..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/bundle/OM.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server.hibernate"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ClassServerInfo.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ClassServerInfo.java
deleted file mode 100644
index 9c581fd273..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ClassServerInfo.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.info;
-
-/**
- * @author Eike Stepper
- */
-public final class ClassServerInfo extends ServerInfo
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/FeatureServerInfo.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/FeatureServerInfo.java
deleted file mode 100644
index df0339ce11..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/FeatureServerInfo.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.info;
-
-/**
- * @author Eike Stepper
- */
-public final class FeatureServerInfo extends ServerInfo
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/PackageServerInfo.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/PackageServerInfo.java
deleted file mode 100644
index be70519c17..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/PackageServerInfo.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.info;
-
-/**
- * @author Eike Stepper
- */
-public final class PackageServerInfo extends ServerInfo
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ServerInfo.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ServerInfo.java
deleted file mode 100644
index 90769ee831..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/info/ServerInfo.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.info;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ServerInfo
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java
deleted file mode 100644
index 15a6f9213a..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2008 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial api
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.id.CDOIDMeta;
-import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-
-import org.hibernate.Hibernate;
-import org.hibernate.usertype.UserType;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-/**
- * @author Martin Taal
- */
-public class CDOIDMetaRangeUserType implements UserType
-{
- private static final int[] SQL_TYPES = { Types.INTEGER, Types.INTEGER };
-
- public CDOIDMetaRangeUserType()
- {
- }
-
- public int[] sqlTypes()
- {
- return SQL_TYPES;
- }
-
- public Class<?> returnedClass()
- {
- return CDOIDMetaRange.class;
- }
-
- public boolean isMutable()
- {
- return true;
- }
-
- public Object deepCopy(Object value)
- {
- if (value == null)
- {
- return null;
- }
-
- CDOIDMetaRange cdoRange = (CDOIDMetaRange)value;
- CDOIDMeta newCdoIDMeta = CDOIDUtil.createMeta(((CDOIDMeta)cdoRange.getLowerBound()).getLongValue());
- return CDOIDUtil.createMetaRange(newCdoIDMeta, cdoRange.size());
- }
-
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException
- {
- Integer start = (Integer)Hibernate.INTEGER.nullSafeGet(rs, names[0]);
- if (rs.wasNull())
- {
- return null;
- }
-
- Integer size = (Integer)Hibernate.INTEGER.nullSafeGet(rs, names[1]);
- if (rs.wasNull())
- {
- return null;
- }
-
- CDOIDMeta newCdoIDMeta = CDOIDUtil.createMeta(start);
- return CDOIDUtil.createMetaRange(newCdoIDMeta, size);
- }
-
- public void nullSafeSet(PreparedStatement statement, Object value, int index) throws SQLException
- {
- if (value != null)
- {
- CDOIDMetaRange cdoRange = (CDOIDMetaRange)value;
- statement.setLong(index, ((CDOIDMeta)cdoRange.getLowerBound()).getLongValue());
- statement.setInt(index + 1, cdoRange.size());
- }
- else
- {
- statement.setNull(index, Types.INTEGER);
- statement.setNull(index + 1, Types.INTEGER);
- }
- }
-
- public Serializable disassemble(Object value)
- {
- return (Serializable)value;
- }
-
- public Object assemble(Serializable cachedValue, Object owner)
- {
- return cachedValue;
- }
-
- public Object replace(Object original, Object target, Object owner)
- {
- return original;
- }
-
- public boolean equals(Object x, Object y)
- {
- if (x == y)
- {
- return true;
- }
-
- if (x == null || y == null)
- {
- return false;
- }
-
- return x.equals(y);
- }
-
- public int hashCode(Object x)
- {
- return x.hashCode();
- }
-}
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
deleted file mode 100644
index cd8c67db80..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-
-/**
- * @author Martin Taal
- */
-public class CDOIDPropertyGetter extends CDOPropertyGetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDPropertyGetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public Object get(Object target) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- if (!(revision.getID() instanceof CDOIDHibernate))
- {
- return null;
- }
-
- CDOIDHibernate cdoID = (CDOIDHibernate)revision.getID();
- if (isVirtualProperty())
- {
- return cdoID.getId();
- }
- else
- {
- Object id = super.get(target);
- // TODO: does this make sense?
- // if (cdoID.getId() == null)
- // {
- // cdoID.setId((Serializable)id);
- // }
- return id;
- }
- }
-
- @Override
- protected boolean isVirtualPropertyAllowed()
- {
- return true;
- }
-}
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
deleted file mode 100644
index bdfc2947c9..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
-import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateFactoryImpl;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateCommitContext;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateThreadContext;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-import java.io.Serializable;
-
-/**
- * @author Martin Taal
- */
-public class CDOIDPropertySetter extends CDOPropertySetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDPropertySetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- if (value == null)
- {
- return;
- }
-
- HibernateCommitContext hcc = null;
- if (HibernateThreadContext.isHibernateCommitContextSet())
- {
- hcc = HibernateThreadContext.getHibernateCommitContext();
- }
- InternalCDORevision revision = (InternalCDORevision)target;
- CDOID cdoID = revision.getID();
- if (cdoID == null)
- {
- CDOIDHibernate newCDOID = CDOIDHibernateFactoryImpl.getInstance().createCDOID((Serializable)value,
- revision.getCDOClass().getName());
- revision.setID(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);
- if (hcc != null)
- {
- hcc.getCommitContext().addIDMapping((CDOIDTemp)cdoID, newCDOID);
- hcc.setNewID(cdoID, newCDOID);
- }
- }
- else
- {
- CDOIDHibernate hbCDOID = (CDOIDHibernate)revision.getID();
- if (!hbCDOID.getId().equals(value))
- {
- throw new IllegalStateException("Current id and new id are different " + value + "/" + hbCDOID.getId());
- }
-
- }
- if (!isVirtualProperty())
- {
- super.set(target, value, factory);
- }
- }
-
- @Override
- protected boolean isVirtualPropertyAllowed()
- {
- return true;
- }
-}
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
deleted file mode 100644
index e03ec49bed..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2008 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial api
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
-import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateFactoryImpl;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.hibernate.Hibernate;
-import org.hibernate.usertype.UserType;
-
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.HashMap;
-
-/**
- * Persists a CDOID in the DB.
- */
-public class CDOIDUserType implements UserType
-{
- /**
- * 1) entityname, 2) id, 3) id class name
- */
- private static final int[] SQL_TYPES = { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR };
-
- /** Constructor by id */
- private final HashMap<String, Constructor<?>> constructors = new HashMap<String, Constructor<?>>();
-
- public CDOIDUserType()
- {
- }
-
- public int[] sqlTypes()
- {
- return SQL_TYPES;
- }
-
- public Class<?> returnedClass()
- {
- return CDOID.class;
- }
-
- public boolean isMutable()
- {
- return false;
- }
-
- public Object deepCopy(Object value)
- {
- return value;
- }
-
- public boolean equals(Object x, Object y)
- {
- if (x == y)
- {
- return true;
- }
-
- if (x == null || y == null)
- {
- return false;
- }
-
- return x.equals(y);
- }
-
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException
- {
- String entityName = (String)Hibernate.STRING.nullSafeGet(rs, names[0]);
- if (rs.wasNull())
- {
- return null;
- }
-
- String idStr = (String)Hibernate.STRING.nullSafeGet(rs, names[1]);
- if (rs.wasNull())
- {
- return null;
- }
-
- String idClassName = (String)Hibernate.STRING.nullSafeGet(rs, names[2]);
- if (rs.wasNull())
- {
- return null;
- }
-
- Serializable id = getId(idStr, idClassName);
- return CDOIDHibernateFactoryImpl.getInstance().createCDOID(id, entityName);
- }
-
- public void nullSafeSet(PreparedStatement statement, Object value, int index) throws SQLException
- {
- if (value == null)
- {
- statement.setNull(index, Types.VARCHAR);
- statement.setNull(index, Types.VARCHAR);
- statement.setNull(index, Types.VARCHAR);
- }
-
- if (value != null)
- {
- CDOIDHibernate cdoID;
- if (value instanceof CDOIDTemp)
- {
- cdoID = HibernateUtil.getInstance().getCDOIDHibernate((CDOID)value);
- }
- else if (value instanceof CDORevision)
- {
- cdoID = (CDOIDHibernate)((CDORevision)value).getID();
- }
- else
- {
- cdoID = (CDOIDHibernate)value;
- }
-
- statement.setString(index, cdoID.getEntityName());
- statement.setString(index + 1, cdoID.getId().toString());
- statement.setString(index + 2, cdoID.getId().getClass().getName());
- }
- }
-
- public Serializable disassemble(Object value)
- {
- return (Serializable)value;
- }
-
- public Object assemble(Serializable cachedValue, Object owner)
- {
- return cachedValue;
- }
-
- public Object replace(Object original, Object target, Object owner)
- {
- return original;
- }
-
- public int hashCode(Object x)
- {
- return x.hashCode();
- }
-
- /** Creates an id object of the correct type */
- private Serializable getId(String idStr, String idType)
- {
- try
- {
- Constructor<?> constructor = constructors.get(idType);
- if (constructor == null)
- {
- Class<?> idClass = this.getClass().getClassLoader().loadClass(idType);
- constructor = idClass.getConstructor(new Class[] { String.class });
- constructors.put(idType, constructor);
- }
-
- return (Serializable)constructor.newInstance(new Object[] { idStr });
- }
- catch (Exception e)
- {
- throw WrappedException.wrap(e);
- }
- }
-}
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
deleted file mode 100644
index c23fd4fcf6..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Springsite B.V. and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.EmptyInterceptor;
-
-/**
- * Resolves entitynames, todo: use entityname strategy!
- *
- * @author Martin Taal
- */
-public class CDOInterceptor extends EmptyInterceptor
-{
- private static final long serialVersionUID = 1L;
-
- public CDOInterceptor()
- {
- }
-
- @Override
- public String getEntityName(Object object)
- {
- InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(object);
- return revision.getCDOClass().getName();
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java
deleted file mode 100644
index 6987480051..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.eclipse.net4j.util.collection.MoveableArrayList;
-import org.eclipse.net4j.util.collection.MoveableList;
-
-import org.hibernate.HibernateException;
-import org.hibernate.collection.PersistentCollection;
-
-/**
- * @author Martin Taal
- */
-// Howto handle hibernate lists:
-// - a new owner: the owner is persisted and its lists are replaced with hibernate
-// persistentlist, the hibernate persitentlist will have a delegate (internally) which is the list which was previously
-// present in the owner.
-// - an existing owner: the owner is read from the db and hibernate will set a persistentlist
-// directly
-//
-// The solution also needs to handle the following:
-// - cdo does not have direct java references but stores cdoids in the list while hibernate expects real java object
-// references.
-// - cdo uses a moveablearraylist and not the standard arraylist
-//
-// The solution:
-// - never return null when hibernate asks for the current value of the manyreference, always
-// return a MoveableArrayList so that hibernate uses that as the delegate, set the MoveableArrayList
-public class CDOManyReferenceGetter extends CDOPropertyGetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOManyReferenceGetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public Object get(Object target) throws HibernateException
- {
- // Check if there is already a persistentcollection
- PersistentCollection collection = PersistableListHolder.getInstance().getListMapping(target, getCDOFeature());
- if (collection != null)
- {
- return collection;
- }
-
- // Not yet, get the moveablearraylist
- @SuppressWarnings("unchecked")
- MoveableList<Object> list = (MoveableList<Object>)super.get(target);
- if (list == null)
- {
- // TODO: what initial size?
- list = new MoveableArrayList<Object>(10);
- InternalCDORevision revision = (InternalCDORevision)target;
- revision.setValue(getCDOFeature(), list);
- }
-
- // Wrap the moveablearraylist
- HibernateMoveableListWrapper wrapper = new HibernateMoveableListWrapper();
- wrapper.setDelegate(list);
-
- // And return it
- return wrapper;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java
deleted file mode 100644
index 6e4f178a24..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.hibernate.HibernateException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.collection.PersistentList;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * @author Martin Taal
- */
-public class CDOManyReferenceSetter extends CDOPropertySetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOManyReferenceSetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- // Do some checking
- if (!(value instanceof PersistentList))
- {
- throw new IllegalArgumentException("Value is not a persistentlist but a " + value.getClass().getName());
- }
-
- // Only set it in the listholder
- PersistableListHolder.getInstance().putListMapping(target, getCDOFeature(), (PersistentCollection)value);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyGetter.java
deleted file mode 100644
index f23c77ca08..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyGetter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionPropertyAccessor.CDORevisionSetter;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.property.Getter;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-/**
- * TODO How does this differ from {@link CDORevisionSetter}? Both needed?
- *
- * @author Martin Taal
- */
-public class CDOPropertyGetter extends CDOPropertyHandler implements Getter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOPropertyGetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- public Object get(Object target) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- return revision.getValue(getCDOFeature());
- }
-
- @SuppressWarnings("unchecked")
- public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException
- {
- return get(target);
- }
-
- public Method getMethod()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Class getReturnType()
- {
- return Object.class;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java
deleted file mode 100644
index a9f263a609..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-/**
- * @author Martin Taal
- */
-public abstract class CDOPropertyHandler
-{
- private final ContextTracer tracer = new ContextTracer(OM.DEBUG, this.getClass());
-
- private CDORevisionTuplizer tuplizer;
-
- private CDOFeature cdoFeature;
-
- private boolean virtualProperty = false;
-
- public CDOPropertyHandler(CDORevisionTuplizer tuplizer, String propertyName)
- {
- this.tuplizer = tuplizer;
- cdoFeature = tuplizer.getCDOClass().lookupFeature(propertyName);
- if (getTracer().isEnabled())
- {
- getTracer().trace(
- "Created " + this.getClass().getName() + " for cdoClass/feature: " + tuplizer.getCDOClass().getName() + "."
- + propertyName);
- }
-
- if (cdoFeature == null)
- {
- if (isVirtualPropertyAllowed())
- {
- virtualProperty = true;
- if (getTracer().isEnabled())
- {
- getTracer().trace("This is a virtual property");
- }
- }
- else
- {
- throw new IllegalStateException("Feature not found: " + propertyName);
- }
- }
- }
-
- protected ContextTracer getTracer()
- {
- return tracer;
- }
-
- public CDORevisionTuplizer getTuplizer()
- {
- return tuplizer;
- }
-
- public CDOFeature getCDOFeature()
- {
- return cdoFeature;
- }
-
- protected boolean isVirtualPropertyAllowed()
- {
- return false;
- }
-
- /**
- * @return the virtualProperty
- */
- public boolean isVirtualProperty()
- {
- return virtualProperty;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java
deleted file mode 100644
index af4e604821..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionPropertyAccessor.CDORevisionSetter;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.property.Setter;
-
-import java.lang.reflect.Method;
-
-/**
- * TODO How does this differ from {@link CDORevisionSetter}? Both needed?
- *
- * @author Martin Taal
- */
-public class CDOPropertySetter extends CDOPropertyHandler implements Setter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOPropertySetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- public Method getMethod()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return null;
- }
-
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- revision.setValue(getCDOFeature(), value);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java
deleted file mode 100644
index e4ef4d174a..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
-
-import org.hibernate.HibernateException;
-
-/**
- * @author Martin Taal
- */
-public class CDOReferenceGetter extends CDOPropertyGetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOReferenceGetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public Object get(Object target) throws HibernateException
- {
- final Object o = super.get(target);
- if (o instanceof CDOID)
- {
- return HibernateUtil.getInstance().getCDORevision((CDOID)o);
- }
-
- return o;
- }
-}
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
deleted file mode 100644
index 1726c14a30..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * @author Martin Taal
- */
-public class CDOReferenceSetter extends CDOPropertySetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOReferenceSetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- if (value == null)
- {
- super.set(target, null, factory);
- }
- else
- {
- CDORevision cdoValue = (CDORevision)value;
- super.set(target, cdoValue.getID(), factory);
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionInstantiator.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionInstantiator.java
deleted file mode 100644
index 5db1c10a9a..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionInstantiator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.model.CDOClass;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IRevisionManager;
-import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateFactoryImpl;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.tuple.Instantiator;
-
-import java.io.Serializable;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionInstantiator implements Instantiator
-{
- private static final long serialVersionUID = 1L;
-
- private CDOClass cdoClass;
-
- private IRevisionManager revisionManager;
-
- public CDORevisionInstantiator(CDORevisionTuplizer tuplizer, PersistentClass mappingInfo)
- {
- cdoClass = tuplizer.getCDOClass();
- HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
- IRepository repository = hbStore.getRepository();
- revisionManager = repository.getRevisionManager();
- }
-
- public Object instantiate()
- {
- // TODO CDO can't create a revision w/o CDOID
- return instantiate(null);
- }
-
- public Object instantiate(Serializable id)
- {
- return CDORevisionUtil.create(revisionManager, cdoClass, CDOIDHibernateFactoryImpl.getInstance().createCDOID(id,
- cdoClass.getName()));
- }
-
- public boolean isInstance(Object object)
- {
- return object instanceof InternalCDORevision;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionLazyInitializer.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionLazyInitializer.java
deleted file mode 100644
index 0a1c9143cc..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionLazyInitializer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.proxy.AbstractLazyInitializer;
-
-import java.io.Serializable;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionLazyInitializer extends AbstractLazyInitializer implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- CDORevisionLazyInitializer(String entityName, Serializable id, SessionImplementor session)
- {
- super(entityName, id, session);
- }
-
- public InternalCDORevision getRevision()
- {
- return (InternalCDORevision)getImplementation();
- }
-
- @SuppressWarnings("unchecked")
- public Class getPersistentClass()
- {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionPropertyAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionPropertyAccessor.java
deleted file mode 100644
index 62dd956bfd..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionPropertyAccessor.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.PropertyNotFoundException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.property.Getter;
-import org.hibernate.property.PropertyAccessor;
-import org.hibernate.property.Setter;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionPropertyAccessor implements PropertyAccessor
-{
- private CDORevisionTuplizer tuplizer;
-
- public CDORevisionPropertyAccessor(CDORevisionTuplizer tuplizer)
- {
- this.tuplizer = tuplizer;
- }
-
- public CDORevisionTuplizer getTuplizer()
- {
- return tuplizer;
- }
-
- @SuppressWarnings("unchecked")
- public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException
- {
- return new CDORevisionGetter(this, propertyName);
- }
-
- @SuppressWarnings("unchecked")
- public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException
- {
- return new CDORevisionSetter(this, propertyName);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class BaseAccessor
- {
- private CDORevisionPropertyAccessor propertyAccessor;
-
- private CDOFeature cdoFeature;
-
- public BaseAccessor(CDORevisionPropertyAccessor propertyAccessor, String propertyName)
- {
- this.propertyAccessor = propertyAccessor;
- cdoFeature = propertyAccessor.getTuplizer().getCDOClass().lookupFeature(propertyName);
- if (cdoFeature == null)
- {
- throw new IllegalStateException("Feature not found: " + propertyName);
- }
- }
-
- public CDORevisionPropertyAccessor getPropertyAccessor()
- {
- return propertyAccessor;
- }
-
- public CDOFeature getCDOFeature()
- {
- return cdoFeature;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class CDORevisionGetter extends BaseAccessor implements Getter
- {
- private static final long serialVersionUID = 1L;
-
- public CDORevisionGetter(CDORevisionPropertyAccessor propertyAccessor, String propertyName)
- {
- super(propertyAccessor, propertyName);
- }
-
- public Object get(Object target) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- return revision.getValue(getCDOFeature());
- }
-
- @SuppressWarnings("unchecked")
- public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException
- {
- return get(target);
- }
-
- public Method getMethod()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Class getReturnType()
- {
- return Object.class;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class CDORevisionSetter extends BaseAccessor implements Setter
- {
- private static final long serialVersionUID = 1L;
-
- public CDORevisionSetter(CDORevisionPropertyAccessor propertyAccessor, String propertyName)
- {
- super(propertyAccessor, propertyName);
- }
-
- public Method getMethod()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return null;
- }
-
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- revision.setValue(getCDOFeature(), value);
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java
deleted file mode 100644
index 2da981e109..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.model.CDOClass;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.common.revision.CDORevisionResolver;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.eclipse.net4j.util.collection.MoveableList;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.proxy.LazyInitializer;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionProxy implements HibernateProxy, InternalCDORevision, Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private CDORevisionLazyInitializer li;
-
- CDORevisionProxy(CDORevisionLazyInitializer li)
- {
- this.li = li;
- }
-
- public Object writeReplace()
- {
- return this;
- }
-
- public LazyInitializer getHibernateLazyInitializer()
- {
- return li;
- }
-
- public void add(CDOFeature feature, int index, Object value)
- {
- li.getRevision().add(feature, index, value);
- }
-
- public void adjustReferences(Map<CDOIDTemp, CDOID> idMappings)
- {
- li.getRevision().adjustReferences(idMappings);
- }
-
- public void clear(CDOFeature feature)
- {
- li.getRevision().clear(feature);
- }
-
- public CDORevisionDelta compare(CDORevision origin)
- {
- return li.getRevision().compare(origin);
- }
-
- public boolean contains(CDOFeature feature, Object value)
- {
- return li.getRevision().contains(feature, value);
- }
-
- public Object get(CDOFeature feature, int index)
- {
- return li.getRevision().get(feature, index);
- }
-
- public CDOClass getCDOClass()
- {
- return li.getRevision().getCDOClass();
- }
-
- public CDOID getContainerID()
- {
- return li.getRevision().getContainerID();
- }
-
- public int getContainingFeatureID()
- {
- return li.getRevision().getContainingFeatureID();
- }
-
- public long getCreated()
- {
- return li.getRevision().getCreated();
- }
-
- public CDORevisionData getData()
- {
- return li.getRevision().getData();
- }
-
- public CDOID getID()
- {
- return li.getRevision().getID();
- }
-
- public MoveableList<Object> getList(CDOFeature feature, int size)
- {
- return li.getRevision().getList(feature, size);
- }
-
- public MoveableList<Object> getList(CDOFeature feature)
- {
- return li.getRevision().getList(feature);
- }
-
- public CDOID getResourceID()
- {
- return li.getRevision().getResourceID();
- }
-
- public long getRevised()
- {
- return li.getRevision().getRevised();
- }
-
- public CDORevision getRevision()
- {
- return li.getRevision().getRevision();
- }
-
- public CDORevisionResolver getRevisionResolver()
- {
- return li.getRevision().getRevisionResolver();
- }
-
- public Object getValue(CDOFeature feature)
- {
- return li.getRevision().getValue(feature);
- }
-
- public int getVersion()
- {
- return li.getRevision().getVersion();
- }
-
- public int hashCode(CDOFeature feature)
- {
- return li.getRevision().hashCode(feature);
- }
-
- public int indexOf(CDOFeature feature, Object value)
- {
- return li.getRevision().indexOf(feature, value);
- }
-
- public boolean isCurrent()
- {
- return li.getRevision().isCurrent();
- }
-
- public boolean isEmpty(CDOFeature feature)
- {
- return li.getRevision().isEmpty(feature);
- }
-
- public boolean isResource()
- {
- return li.getRevision().isResource();
- }
-
- public boolean isSet(CDOFeature feature)
- {
- return li.getRevision().isSet(feature);
- }
-
- public boolean isTransactional()
- {
- return li.getRevision().isTransactional();
- }
-
- public boolean isValid(long timeStamp)
- {
- return li.getRevision().isValid(timeStamp);
- }
-
- public int lastIndexOf(CDOFeature feature, Object value)
- {
- return li.getRevision().lastIndexOf(feature, value);
- }
-
- public void merge(CDORevisionDelta delta)
- {
- li.getRevision().merge(delta);
- }
-
- public Object move(CDOFeature feature, int targetIndex, int sourceIndex)
- {
- return li.getRevision().move(feature, targetIndex, sourceIndex);
- }
-
- public Object remove(CDOFeature feature, int index)
- {
- return li.getRevision().remove(feature, index);
- }
-
- public Object set(CDOFeature feature, int index, Object value)
- {
- return li.getRevision().set(feature, index, value);
- }
-
- public void setContainerID(CDOID containerID)
- {
- li.getRevision().setContainerID(containerID);
- }
-
- public void setContainingFeatureID(int containingFeatureID)
- {
- li.getRevision().setContainingFeatureID(containingFeatureID);
- }
-
- public void setCreated(long created)
- {
- li.getRevision().setCreated(created);
- }
-
- public void setID(CDOID id)
- {
- li.getRevision().setID(id);
- }
-
- public void setListSize(CDOFeature feature, int size)
- {
- li.getRevision().setListSize(feature, size);
- }
-
- public void setResourceID(CDOID resourceID)
- {
- li.getRevision().setResourceID(resourceID);
- }
-
- public void setRevised(long revised)
- {
- li.getRevision().setRevised(revised);
- }
-
- public int setTransactional()
- {
- return li.getRevision().setTransactional();
- }
-
- public void setUntransactional()
- {
- li.getRevision().setUntransactional();
- }
-
- public Object setValue(CDOFeature feature, Object value)
- {
- return li.getRevision().setValue(feature, value);
- }
-
- public void setVersion(int version)
- {
- li.getRevision().setVersion(version);
- }
-
- public int size(CDOFeature feature)
- {
- return li.getRevision().size(feature);
- }
-
- public <T> T[] toArray(CDOFeature feature, T[] array)
- {
- return li.getRevision().toArray(feature, array);
- }
-
- public Object[] toArray(CDOFeature feature)
- {
- return li.getRevision().toArray(feature);
- }
-
- public void unset(CDOFeature feature)
- {
- li.getRevision().unset(feature);
- }
-
- public void write(ExtendedDataOutput out, CDOIDProvider idProvider, int referenceChunk) throws IOException
- {
- li.getRevision().write(out, idProvider, referenceChunk);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxyFactory.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxyFactory.java
deleted file mode 100644
index 320f6e1469..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxyFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.proxy.ProxyFactory;
-import org.hibernate.type.AbstractComponentType;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionProxyFactory implements ProxyFactory
-{
- private String entityName;
-
- public CDORevisionProxyFactory()
- {
- }
-
- @SuppressWarnings("unchecked")
- public void postInstantiate(String entityName, Class persistentClass, Set interfaces, Method getIdentifierMethod,
- Method setIdentifierMethod, AbstractComponentType componentIdType) throws HibernateException
- {
- this.entityName = entityName;
- }
-
- public HibernateProxy getProxy(Serializable id, SessionImplementor session) throws HibernateException
- {
- return new CDORevisionProxy(new CDORevisionLazyInitializer(entityName, id, session));
- }
-}
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
deleted file mode 100644
index aaafdc0aa7..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany, and others
- * All rights reserved. This program and the accompanying materials
- * 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:
- * Eike Stepper - initial API and implementation
- * Martin Taal - changed handling of propertygetters/setters
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.model.CDOClass;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
-import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.property.Getter;
-import org.hibernate.property.Setter;
-import org.hibernate.proxy.ProxyFactory;
-import org.hibernate.tuple.Instantiator;
-import org.hibernate.tuple.entity.AbstractEntityTuplizer;
-import org.hibernate.tuple.entity.EntityMetamodel;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionTuplizer extends AbstractEntityTuplizer
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDORevisionTuplizer.class);
-
- private CDOClass cdoClass;
-
- public CDORevisionTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
- {
- super(entityMetamodel, mappingInfo);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Created CDORevisionTuplizer for entity " + mappingInfo.getEntityName());
- }
-
- initCDOClass(mappingInfo);
- }
-
- private void initCDOClass(PersistentClass mappingInfo)
- {
- if (cdoClass != null)
- {
- return;
- }
-
- HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
-
- // find the CDOClass/Package
- // TODO: error handling if meta attribute not present
- // TODO: error handling if entityname not set
- String entityName = mappingInfo.getEntityName();
- String ePackageURI = mappingInfo.getMetaAttribute("epackage").getValue();
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("EntityName/packageURI " + entityName + " " + ePackageURI);
- }
-
- for (CDOPackage cdoPackage : hbStore.getPackageHandler().getCDOPackages())
- {
- if (cdoPackage.getPackageURI().compareTo(ePackageURI) != 0)
- {
- continue;
- }
-
- for (CDOClass localCdoClass : cdoPackage.getClasses())
- {
- if (localCdoClass.getName().compareTo(entityName) == 0)
- {
- cdoClass = localCdoClass;
- break;
- }
- }
- }
-
- if (cdoClass == null && ePackageURI.compareTo(CDOResourcePackage.PACKAGE_URI) == 0)
- {
- for (CDOClass localCdoClass : hbStore.getRepository().getPackageManager().getCDOResourcePackage().getClasses())
- {
- if (localCdoClass.getName().compareTo(entityName) == 0)
- {
- cdoClass = localCdoClass;
- if (TRACER.isEnabled())
- {
- TRACER.trace("Class is CDOResource class");
- }
-
- break;
- }
- }
- }
-
- if (cdoClass == null)
- {
- throw new IllegalArgumentException("The mapped class " + mappingInfo.getEntityName());
- }
- }
-
- // 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");
- // }
-
- @Override
- public EntityMode getEntityMode()
- {
- return EntityMode.MAP;
- }
-
- public CDOClass getCDOClass()
- {
- return cdoClass;
- }
-
- @Override
- protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity)
- {
- initCDOClass(mappedEntity);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Building property getter for " + cdoClass.getName() + "." + mappedProperty.getName());
- }
-
- if (mappedProperty.isBackRef())
- {
- return mappedProperty.getGetter(mappedEntity.getMappedClass());
- }
- else if (mappedProperty == mappedEntity.getIdentifierProperty())
- {
- return new CDOIDPropertyGetter(this, mappedProperty.getName());
- }
- else if (mappedProperty == mappedEntity.getVersion())
- {
- return new CDOVersionPropertyGetter(this, mappedProperty.getName());
- }
-
- CDOFeature cdoFeature = getCDOClass().lookupFeature(mappedProperty.getName());
- if (cdoFeature.isReference() && cdoFeature.isMany())
- {
- return new CDOManyReferenceGetter(this, mappedProperty.getName());
- }
- else if (cdoFeature.isReference())
- {
- return new CDOReferenceGetter(this, mappedProperty.getName());
- }
-
- return new CDOPropertyGetter(this, mappedProperty.getName());
- }
-
- @Override
- protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity)
- {
- initCDOClass(mappedEntity);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Building property setter for " + cdoClass.getName() + "." + mappedProperty.getName());
- }
-
- if (mappedProperty.isBackRef())
- {
- return mappedProperty.getSetter(mappedEntity.getMappedClass());
- }
- else if (mappedProperty == mappedEntity.getIdentifierProperty())
- {
- return new CDOIDPropertySetter(this, mappedProperty.getName());
- }
- else if (mappedProperty == mappedEntity.getVersion())
- {
- return new CDOVersionPropertySetter(this, mappedProperty.getName());
- }
-
- CDOFeature cdoFeature = getCDOClass().lookupFeature(mappedProperty.getName());
- if (cdoFeature.isReference() && cdoFeature.isMany())
- {
- return new CDOManyReferenceSetter(this, mappedProperty.getName());
- }
- else if (cdoFeature.isReference())
- {
- return new CDOReferenceSetter(this, mappedProperty.getName());
- }
-
- return new CDOPropertySetter(this, mappedProperty.getName());
- }
-
- @Override
- protected Instantiator buildInstantiator(PersistentClass mappingInfo)
- {
- return new CDORevisionInstantiator(this, mappingInfo);
- }
-
- @Override
- protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter)
- {
- ProxyFactory pf = new CDORevisionProxyFactory();
-
- try
- {
- pf.postInstantiate(getEntityName(), null, null, null, null, null);
- }
- catch (HibernateException ex)
- {
- OM.LOG.error("Could not create proxy factory for " + getEntityName(), ex);
- pf = null;
- }
-
- return pf;
- }
-
- @SuppressWarnings("unchecked")
- public Class getMappedClass()
- {
- return InternalCDORevision.class;
- }
-
- @SuppressWarnings("unchecked")
- public Class getConcreteProxyClass()
- {
- return InternalCDORevision.class;
- }
-
- public boolean isInstrumented()
- {
- return false;
- }
-}
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
deleted file mode 100644
index 3e19ef47e2..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others
- * All rights reserved. This program and the accompanying materials
- * 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
- * </copyright>
- *
- * $Id: CDOSyntheticIdPropertyHandler.java,v 1.5 2008-06-15 20:47:36 mtaal Exp $
- */
-
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
-import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateFactoryImpl;
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateCommitContext;
-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.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.PropertyNotFoundException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.property.Getter;
-import org.hibernate.property.PropertyAccessor;
-import org.hibernate.property.Setter;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-/**
- * Is only used for synthetic id's.
- *
- * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5 $
- */
-@SuppressWarnings("unchecked")
-public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAccessor
-{
- private static final long serialVersionUID = 1L;
-
- public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException
- {
- return this;
- }
-
- public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException
- {
- return this;
- }
-
- public Object get(Object owner) throws HibernateException
- {
- InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(owner);
- if (revision == null)
- {
- return null;
- }
-
- if (!(revision.getID() instanceof CDOIDHibernate))
- {
- return null;
- }
-
- CDOIDHibernate cdoID = (CDOIDHibernate)revision.getID();
- return cdoID.getId();
- }
-
- public Object getForInsert(Object arg0, Map arg1, SessionImplementor arg2) throws HibernateException
- {
- return get(arg0);
- }
-
- public Method getMethod()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return null;
- }
-
- public Class getReturnType()
- {
- return null;
- }
-
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- if (value == null)
- {
- return;
- }
-
- HibernateCommitContext hcc = null;
- if (HibernateThreadContext.isHibernateCommitContextSet())
- {
- hcc = HibernateThreadContext.getHibernateCommitContext();
- }
-
- InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(target);
- CDOID cdoID = revision.getID();
- if (cdoID == null)
- {
- CDOIDHibernate newCDOID = CDOIDHibernateFactoryImpl.getInstance().createCDOID((Serializable)value,
- revision.getCDOClass().getName());
- revision.setID(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);
- if (hcc != null)
- {
- hcc.getCommitContext().addIDMapping((CDOIDTemp)cdoID, newCDOID);
- hcc.setNewID(cdoID, newCDOID);
- }
- }
- else
- {
- CDOIDHibernate hbCDOID = (CDOIDHibernate)revision.getID();
- if (!hbCDOID.getId().equals(value))
- {
- throw new IllegalStateException("Current id and new id are different " + value + "/" + hbCDOID.getId());
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticVersionPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticVersionPropertyHandler.java
deleted file mode 100644
index c998ea2f44..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticVersionPropertyHandler.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others
- * All rights reserved. This program and the accompanying materials
- * 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
- * </copyright>
- *
- * $Id: CDOSyntheticVersionPropertyHandler.java,v 1.3 2008-06-03 09:45:56 estepper Exp $
- */
-
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil;
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.PropertyNotFoundException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.property.Getter;
-import org.hibernate.property.PropertyAccessor;
-import org.hibernate.property.Setter;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-/**
- * Reads the version from the internal version cache.
- *
- * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.3 $
- */
-@SuppressWarnings("unchecked")
-public class CDOSyntheticVersionPropertyHandler implements Getter, Setter, PropertyAccessor
-{
- private static final long serialVersionUID = 1L;
-
- public CDOSyntheticVersionPropertyHandler()
- {
- }
-
- public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException
- {
- return this;
- }
-
- public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException
- {
- return this;
- }
-
- public Object get(Object owner) throws HibernateException
- {
- InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(owner);
- if (revision == null)
- {
- return null;
- }
-
- return revision.getVersion();
- }
-
- /**
- * Reads the version from the versioncache
- */
- public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) throws HibernateException
- {
- return get(owner);
- }
-
- public Method getMethod()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return null;
- }
-
- /** Returns Integer.class */
- public Class getReturnType()
- {
- return Integer.class;
- }
-
- /** Sets the version in the internal version cache */
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(target);
- revision.setVersion(((Number)value).intValue());
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java
deleted file mode 100644
index ee5b80f891..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2008 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial api
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-
-import org.hibernate.Hibernate;
-import org.hibernate.usertype.UserType;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-/**
- * @author Martin Taal
- */
-public class CDOTypeUserType implements UserType
-{
- private static final int[] SQL_TYPES = { Types.INTEGER };
-
- public CDOTypeUserType()
- {
- }
-
- public int[] sqlTypes()
- {
- return SQL_TYPES;
- }
-
- public Class<?> returnedClass()
- {
- return CDOType.class;
- }
-
- public boolean isMutable()
- {
- return false;
- }
-
- public Object deepCopy(Object value)
- {
- return value;
- }
-
- public boolean equals(Object x, Object y)
- {
- if (x == y)
- {
- return true;
- }
-
- if (x == null || y == null)
- {
- return false;
- }
-
- return x.equals(y);
- }
-
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException
- {
- Integer value = (Integer)Hibernate.INTEGER.nullSafeGet(rs, names[0]);
- if (rs.wasNull())
- {
- return null;
- }
-
- if (value == null)
- {
- return null;
- }
-
- return CDOModelUtil.getType(value);
- }
-
- public void nullSafeSet(PreparedStatement statement, Object value, int index) throws SQLException
- {
- if (value != null)
- {
- statement.setInt(index, ((CDOType)value).getTypeID());
- }
- else
- {
- statement.setNull(index, Types.INTEGER);
- }
- }
-
- public Serializable disassemble(Object value)
- {
- return (Serializable)value;
- }
-
- public Object assemble(Serializable cachedValue, Object owner)
- {
- return cachedValue;
- }
-
- public Object replace(Object original, Object target, Object owner)
- {
- return original;
- }
-
- public int hashCode(Object x)
- {
- return x.hashCode();
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java
deleted file mode 100644
index 2f366219fa..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-
-/**
- * @author Martin Taal
- */
-public class CDOVersionPropertyGetter extends CDOPropertyGetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOVersionPropertyGetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public Object get(Object target) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- if (isVirtualProperty())
- {
- return revision.getVersion();
- }
-
- Object version = super.get(target);
- // TODO: does this make sense?
- // revision.setVersion(((Number)value).intValue());
- return version;
- }
-
- @Override
- protected boolean isVirtualPropertyAllowed()
- {
- return true;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java
deleted file mode 100644
index c0b7a9e019..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * @author Martin Taal
- */
-public class CDOVersionPropertySetter extends CDOPropertySetter
-{
- private static final long serialVersionUID = 1L;
-
- public CDOVersionPropertySetter(CDORevisionTuplizer tuplizer, String propertyName)
- {
- super(tuplizer, propertyName);
- }
-
- @Override
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
- {
- InternalCDORevision revision = (InternalCDORevision)target;
- revision.setVersion(((Number)value).intValue());
- if (!isVirtualProperty())
- {
- super.set(target, value, factory);
- }
- }
-
- @Override
- protected boolean isVirtualPropertyAllowed()
- {
- return true;
- }
-}
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
deleted file mode 100644
index 9234a5d54d..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2008 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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 - initial api
- **************************************************************************/
-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.HibernateUtil;
-
-import org.eclipse.net4j.util.collection.MoveableList;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * Wraps a moveable list so that hibernate always sees an object view while cdo always sees a cdoid view.
- *
- * @author Martin Taal
- */
-public class HibernateMoveableListWrapper implements List<Object>
-{
- private MoveableList<Object> delegate;
-
- public HibernateMoveableListWrapper()
- {
- }
-
- /**
- * @return the delegate
- */
- public MoveableList<Object> getDelegate()
- {
- return delegate;
- }
-
- /**
- * @param delegate
- * the delegate to set
- */
- public void setDelegate(MoveableList<Object> delegate)
- {
- this.delegate = delegate;
- }
-
- protected Object getObject(Object o)
- {
- if (o == null)
- {
- return null;
- }
-
- // is already resolved
- if (!(o instanceof CDOID))
- {
- return o;
- }
-
- return HibernateUtil.getInstance().getCDORevision((CDOID)o);
- }
-
- protected List<Object> getObjects(List<?> cdoIDs)
- {
- List<Object> result = new ArrayList<Object>();
- for (Object o : cdoIDs)
- {
- result.add(getObject(o));
- }
-
- return result;
- }
-
- protected CDOID getCDOID(Object o)
- {
- CDORevision cdoRevision = (CDORevision)o;
- return cdoRevision.getID();
- }
-
- protected List<CDOID> getCDOIDs(Collection<?> c)
- {
- List<CDOID> newC = new ArrayList<CDOID>();
- for (Object o : c)
- {
- newC.add(getCDOID(o));
- }
-
- return newC;
- }
-
- public void add(int index, Object element)
- {
- getDelegate().add(index, getCDOID(element));
- }
-
- public boolean add(Object o)
- {
- return getDelegate().add(getCDOID(o));
- }
-
- public boolean addAll(Collection<? extends Object> c)
- {
- return getDelegate().addAll(getCDOIDs(c));
- }
-
- public boolean addAll(int index, Collection<? extends Object> c)
- {
- return getDelegate().addAll(index, getCDOIDs(c));
- }
-
- public void clear()
- {
- getDelegate().clear();
- }
-
- public boolean contains(Object o)
- {
- return getDelegate().contains(getCDOID(o));
- }
-
- public boolean containsAll(Collection<?> c)
- {
- return getDelegate().containsAll(getCDOIDs(c));
- }
-
- public Object get(int index)
- {
- return getObject(getDelegate().get(index));
- }
-
- public int indexOf(Object o)
- {
- return getDelegate().indexOf(getCDOID(o));
- }
-
- public boolean isEmpty()
- {
- return getDelegate().isEmpty();
- }
-
- public Iterator<Object> iterator()
- {
- return new CDOHibernateIterator(getDelegate().iterator());
- }
-
- public int lastIndexOf(Object o)
- {
- return getDelegate().lastIndexOf(getCDOID(o));
- }
-
- public ListIterator<Object> listIterator()
- {
- return new CDOHibernateListIterator(getDelegate().listIterator());
- }
-
- public ListIterator<Object> listIterator(int index)
- {
- return new CDOHibernateListIterator(getDelegate().listIterator(index));
- }
-
- public Object remove(int index)
- {
- return getDelegate().remove(index);
- }
-
- public boolean remove(Object o)
- {
- return getDelegate().remove(getCDOID(o));
- }
-
- public boolean removeAll(Collection<?> c)
- {
- return getDelegate().removeAll(getCDOIDs(c));
- }
-
- public boolean retainAll(Collection<?> c)
- {
- return getDelegate().retainAll(getCDOIDs(c));
- }
-
- public Object set(int index, Object element)
- {
- return getDelegate().set(index, getCDOID(element));
- }
-
- public int size()
- {
- return getDelegate().size();
- }
-
- public List<Object> subList(int fromIndex, int toIndex)
- {
- return getObjects(getDelegate().subList(fromIndex, toIndex));
- }
-
- public Object[] toArray()
- {
- Object[] result = new Object[size()];
- int i = 0;
- for (Object o : this)
- {
- result[i++] = o;
- }
-
- return result;
- }
-
- @SuppressWarnings("unchecked")
- public <T> T[] toArray(T[] a)
- {
- int i = 0;
- for (Object o : this)
- {
- a[i++] = (T)o;
- }
-
- return a;
- }
-
- private static final class CDOHibernateIterator implements Iterator<Object>
- {
- private final Iterator<?> delegate;
-
- public CDOHibernateIterator(Iterator<?> delegate)
- {
- this.delegate = delegate;
- }
-
- public boolean hasNext()
- {
- return delegate.hasNext();
- }
-
- public Object next()
- {
- Object o = delegate.next();
- if (o instanceof CDOID)
- {
- return HibernateUtil.getInstance().getCDORevision((CDOID)o);
- }
-
- return o;
- }
-
- public void remove()
- {
- delegate.remove();
- }
- }
-
- private static final class CDOHibernateListIterator implements ListIterator<Object>
- {
- private final ListIterator<Object> delegate;
-
- public CDOHibernateListIterator(ListIterator<Object> delegate)
- {
- this.delegate = delegate;
- }
-
- public void add(Object o)
- {
- delegate.add(((CDORevision)o).getID());
- }
-
- public boolean hasNext()
- {
- return delegate.hasNext();
- }
-
- public boolean hasPrevious()
- {
- return delegate.hasPrevious();
- }
-
- public Object next()
- {
- Object o = delegate.next();
- if (o instanceof CDOID)
- {
- return HibernateUtil.getInstance().getCDORevision((CDOID)delegate.next());
- }
-
- return o;
- }
-
- public int nextIndex()
- {
- return delegate.nextIndex();
- }
-
- public Object previous()
- {
- Object o = delegate.previous();
- if (o instanceof CDOID)
- {
- return HibernateUtil.getInstance().getCDORevision((CDOID)delegate.next());
- }
-
- return o;
- }
-
- public int previousIndex()
- {
- return delegate.previousIndex();
- }
-
- public void remove()
- {
- delegate.remove();
- }
-
- public void set(Object o)
- {
- delegate.set(((CDORevision)o).getID());
- }
- }
-}
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
deleted file mode 100644
index 108747dca9..0000000000
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Martin Taal and others
- * All rights reserved. This program and the accompanying materials
- * 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
- **************************************************************************/
-package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
-
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-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.hibernate.collection.PersistentCollection;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Keeps mappings from object/feature combinations to a hibernate persistable list. This works because the write action
- * is done in one thread.
- *
- * @author Martin Taal
- */
-public class PersistableListHolder
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, PersistableListHolder.class);
-
- private static PersistableListHolder instance = new PersistableListHolder();
-
- private ThreadLocal<Map<Key, PersistentCollection>> listMapping = new ThreadLocal<Map<Key, PersistentCollection>>();
-
- public PersistableListHolder()
- {
- }
-
- public void putListMapping(Object target, CDOFeature cdoFeature, PersistentCollection collection)
- {
- Key key = new Key(target, cdoFeature);
- getListMapping().put(key, collection);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Stored hb list in threadlocal: " + ((CDORevision)target).getCDOClass().getName() + "."
- + cdoFeature.getName());
- }
- }
-
- public PersistentCollection getListMapping(Object target, CDOFeature cdoFeature)
- {
- Key key = new Key(target, cdoFeature);
- return getListMapping().get(key);
- }
-
- private Map<Key, PersistentCollection> getListMapping()
- {
- if (listMapping.get() == null)
- {
- listMapping.set(new HashMap<Key, PersistentCollection>());
- }
-
- return listMapping.get();
- }
-
- public static PersistableListHolder getInstance()
- {
- return instance;
- }
-
- public static void setInstance(PersistableListHolder instance)
- {
- PersistableListHolder.instance = instance;
- }
-
- private static final class Key
- {
- private Object owner;
-
- private CDOFeature cdoFeature;
-
- public Key(Object owner, CDOFeature cdoFeature)
- {
- this.owner = owner;
- this.cdoFeature = cdoFeature;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (!(obj instanceof Key))
- {
- return false;
- }
-
- Key otherKey = (Key)obj;
- // the owner is uniquely present in mem, the same applies for the cdoFeature
- // therefore == is allowed
- return owner == otherKey.owner && cdoFeature == otherKey.cdoFeature;
- }
-
- @Override
- public int hashCode()
- {
- return owner.hashCode() + cdoFeature.hashCode();
- }
- }
-}

Back to the top