summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-02-26 14:30:48 (EST)
committerEike Stepper2008-02-26 14:30:48 (EST)
commit610c588f732f2a2ca90a0b0d722b7a72e9b4d9c7 (patch)
treebe0f7a8a73a5ae8bf8143169904714d5619783a0
parent6c2e92fdedff724786ab87a6d4242b3cfd506167 (diff)
downloadcdo-610c588f732f2a2ca90a0b0d722b7a72e9b4d9c7.zip
cdo-610c588f732f2a2ca90a0b0d722b7a72e9b4d9c7.tar.gz
cdo-610c588f732f2a2ca90a0b0d722b7a72e9b4d9c7.tar.bz2
[217117] Develop a HibernateStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=217117
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/mappings/meta.hbm.xml1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java (renamed from plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/HibernateUtil.java)8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java53
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreReader.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreWriter.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/id/CDOIDHibernateImpl.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyGetter.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java4
27 files changed, 335 insertions, 157 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/meta.hbm.xml b/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/meta.hbm.xml
index 68159ef..b7413ee 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/meta.hbm.xml
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/meta.hbm.xml
@@ -26,7 +26,6 @@
<list-index />
<one-to-many class="CDOClassImpl" />
</list>
-
</joined-subclass>
<class name="CDOClassProxy" table="cdo_classes_proxy" lazy="false">
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
index ee5c741..1f68894 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/HibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
@@ -19,14 +19,14 @@ import java.util.Properties;
* @author Eike Stepper
* @author Martin Taal
*/
-public final class HibernateUtil
+public final class CDOHibernateUtil
{
- private HibernateUtil()
+ private CDOHibernateUtil()
{
}
- public static IHibernateStore createStore(Properties properties, IHibernateMappingProvider mappingProvider)
+ public static IHibernateStore createStore(IHibernateMappingProvider mappingProvider, Properties properties)
{
- return new HibernateStore(properties, mappingProvider);
+ return new HibernateStore(mappingProvider, properties);
}
}
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
index 384a273..7c5a341 100644
--- 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
@@ -65,15 +65,21 @@ public class HibernatePackageHandler
private HibernateStore hibernateStore;
- public HibernatePackageHandler(Properties props, HibernateStore hibernateStore)
+ /**
+ * TODO Necessary to pass/store/dump the properties from the store?
+ */
+ public HibernatePackageHandler(HibernateStore store, Properties properties)
{
- properties = props;
- this.hibernateStore = hibernateStore;
- TRACER.trace("Created " + this.getClass().getName() + " with properties:");
- for (Object keyObject : props.keySet())
- {
- TRACER.trace("Property: " + keyObject + ": " + props.get(keyObject));
- }
+ hibernateStore = store;
+ this.properties = properties;
+ // if (TRACER.isEnabled())
+ // {
+ // TRACER.format("Created {0} with properties:", getClass().getName());
+ // for (Entry<Object, Object> property : properties.entrySet())
+ // {
+ // TRACER.format("Property: {0} = {1}", property.getKey(), property.getValue());
+ // }
+ // }
}
public void writePackages(CDOPackage... cdoPackages)
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
index a2d7a96..fd8425e 100644
--- 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
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.server.internal.hibernate.id.CDOIDHibernateFactoryImp
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.io.IOUtil;
import org.hibernate.SessionFactory;
@@ -33,6 +34,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
+import java.util.Map.Entry;
/**
* @author Eike Stepper
@@ -57,25 +59,38 @@ public class HibernateStore extends Store implements IHibernateStore
private HibernatePackageHandler packageHandler;
- @SuppressWarnings("unused")
private IHibernateMappingProvider mappingProvider;
+ // Exclude from dump due to contained db password
+ // TODO Can't the properties of Store.java be used?
+ @ExcludeFromDump
private Properties properties;
- public HibernateStore(Properties props, IHibernateMappingProvider mappingProvider)
+ public HibernateStore(IHibernateMappingProvider mappingProvider, Properties properties)
{
super(TYPE);
- properties = props;
- packageHandler = new HibernatePackageHandler(props, this);
this.mappingProvider = mappingProvider;
- TRACER.trace("Created " + this.getClass().getName() + " with properties:");
- for (Object keyObject : props.keySet())
+ this.properties = properties;
+ packageHandler = new HibernatePackageHandler(this, properties);
+ if (TRACER.isEnabled())
{
- TRACER.trace("Property: " + keyObject + ": " + props.get(keyObject));
- }
- if (mappingProvider != null)
- {
- TRACER.trace("With mappingProvider " + mappingProvider.getClass().getName());
+ TRACER.format("Created {0} with properties:", getClass().getName());
+ for (Entry<Object, Object> property : properties.entrySet())
+ {
+ Object key = property.getKey();
+ Object value = property.getValue();
+ if (key instanceof String && ((String)key).contains("password"))
+ {
+ value = "****************";
+ }
+
+ TRACER.format("Property: {0} = {1}", key, value);
+ }
+
+ if (mappingProvider != null)
+ {
+ TRACER.trace("With mappingProvider " + mappingProvider.getClass().getName());
+ }
}
}
@@ -88,8 +103,13 @@ public class HibernateStore extends Store implements IHibernateStore
{
if (hibernateSessionFactory == null)
{
- TRACER.trace("Initializing SessionFactory for HibernateStore");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Initializing SessionFactory for HibernateStore");
+ }
+
currentHibernateStore.set(this);
+
try
{
hibernateSessionFactory = hibernateConfiguration.buildSessionFactory();
@@ -177,15 +197,18 @@ public class HibernateStore extends Store implements IHibernateStore
return packageHandler;
}
- @Override
// TODO: synchronize??
+ @Override
protected void doActivate() throws Exception
{
- TRACER.trace("Activating HibernateStore");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Activating HibernateStore");
+ }
super.doActivate();
- // activate the package store
+ // Activate the package store
packageHandler.doActivate();
initConfiguration();
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index 7853fbc..16def07 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -35,18 +35,28 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
protected HibernateStoreAccessor(HibernateStore store, ISession session)
{
super(store, session);
- TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ }
}
protected HibernateStoreAccessor(HibernateStore store, IView view)
{
super(store, view);
- TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ }
}
protected Session createHibernateSession()
{
- TRACER.trace("Creating hibernate session and setting it in threadlocal HibernateThreadContext");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Creating hibernate session and setting it in threadlocal HibernateThreadContext");
+ }
+
final SessionFactory sessionFactory = getStore().getHibernateSessionFactory();
final Session session = sessionFactory.openSession();
HibernateThreadContext.setSession(session);
@@ -56,7 +66,11 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
@Override
protected void doRelease()
{
- TRACER.trace("Releasing hibernate session");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Releasing hibernate session");
+ }
+
HibernateThreadContext.setSession(null);
clearHibernateSession();
}
@@ -76,12 +90,21 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
public void clearHibernateSession()
{
- TRACER.trace("Removing hibernate session");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Removing hibernate session");
+ }
+
if (hibernateSession != null && hibernateSession.isOpen())
{
- TRACER.trace("Closing hibernate session");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Closing hibernate session");
+ }
+
hibernateSession.close();
}
+
hibernateSession = null;
}
@@ -91,6 +114,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
{
hibernateSession = createHibernateSession();
}
+
return hibernateSession;
}
}
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
index cc4e500..e8cc824 100644
--- 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
@@ -46,13 +46,19 @@ public class HibernateStoreReader extends HibernateStoreAccessor implements IHib
public HibernateStoreReader(HibernateStore store, ISession session)
{
super(store, session);
- TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ }
}
protected HibernateStoreReader(HibernateStore store, IView view)
{
super(store, view);
- TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Created " + this.getClass().getName() + " for repository " + store.getRepository().getName());
+ }
}
public HibernateStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature)
@@ -73,7 +79,7 @@ public class HibernateStoreReader extends HibernateStoreAccessor implements IHib
public void readPackage(CDOPackage cdoPackage)
{
- // does nothing, assumes that the packages have been read
+ // Does nothing, assumes that the packages have been read
}
public Collection<CDOPackageInfo> readPackageInfos()
@@ -83,18 +89,26 @@ public class HibernateStoreReader extends HibernateStoreAccessor implements IHib
public CDOID readResourceID(String path)
{
- TRACER.trace("Finding resourceid using path " + path);
- final Session session = getHibernateSession();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Finding resourceid using path " + path);
+ }
+ final Session session = getHibernateSession();
final Criteria criteria = session.createCriteria(CDOResourceClass.NAME);
criteria.add(Expression.eq("path", path));
final List<?> result = criteria.list();
if (result.size() == 0)
{
- TRACER.trace("Resource not found");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Resource not found");
+ }
+
// TODO: throw exception?
return null;
}
+
// TODO: throw exception if list.size() > 1?
final CDORevision cdoRevision = (CDORevision)result.get(0);
return cdoRevision.getID();
@@ -106,12 +120,16 @@ public class HibernateStoreReader extends HibernateStoreAccessor implements IHib
{
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");
}
- TRACER.trace("Finding resource using id " + id);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Finding resource using id " + id);
+ }
final Session session = getHibernateSession();
final Query qry = session.createQuery("select path from " + CDOResourceClass.NAME + " where id=:id");
@@ -120,10 +138,15 @@ public class HibernateStoreReader extends HibernateStoreAccessor implements IHib
final List<?> result = qry.list();
if (result.size() == 0)
{
- TRACER.trace("Resource not found");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Resource not found");
+ }
+
// TODO: throw exception?
return null;
}
+
return (String)result.get(0);
}
@@ -139,6 +162,7 @@ public class HibernateStoreReader extends HibernateStoreAccessor implements IHib
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
index d0803e4..f59ce1c 100644
--- 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
@@ -42,7 +42,10 @@ public class HibernateStoreWriter extends HibernateStoreReader implements IHiber
@Override
public void commit(CommitContext context)
{
- TRACER.trace("Committing transaction");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Committing transaction");
+ }
writePackages(context.getNewPackages());
@@ -57,39 +60,62 @@ public class HibernateStoreWriter extends HibernateStoreReader implements IHiber
{
final CDORevision cdoRevision = (CDORevision)o;
session.save(HibernateUtil.getInstance().getEntityName(cdoRevision), o);
- TRACER
- .trace("Persisted new Object " + ((CDORevision)o).getCDOClass().getName() + " id: " + cdoRevision.getID());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Persisted new Object " + ((CDORevision)o).getCDOClass().getName() + " id: "
+ + cdoRevision.getID());
+ }
}
+
for (Object o : context.getDirtyObjects())
{
final CDORevision cdoRevision = (CDORevision)o;
session.update(HibernateUtil.getInstance().getEntityName(cdoRevision), o);
- TRACER.trace("Updated Object " + ((CDORevision)o).getCDOClass().getName() + " id: " + cdoRevision.getID());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Updated Object " + ((CDORevision)o).getCDOClass().getName() + " id: " + cdoRevision.getID());
+ }
}
- TRACER.trace("Commit hibernate transaction");
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Commit hibernate transaction");
+ }
+
session.getTransaction().commit();
}
finally
{
- TRACER.trace("Clearing used hibernate session");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Clearing used hibernate session");
+ }
+
HibernateThreadContext.setCommitContext(null);
}
- TRACER.trace("Applying id mappings");
+ 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)
- TRACER.trace("Rollbacked called");
+ // 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
@@ -107,12 +133,12 @@ public class HibernateStoreWriter extends HibernateStoreReader implements IHiber
@Override
protected void writePackages(CDOPackage... cdoPackages)
{
- if (cdoPackages != null && cdoPackages.length > 0)
+ if (cdoPackages != null && cdoPackages.length != 0)
{
getStore().getPackageHandler().writePackages(cdoPackages);
}
- // set a new hibernatesession in the thread
+ // Set a new hibernatesession in the thread
resetHibernateSession();
}
@@ -125,7 +151,7 @@ public class HibernateStoreWriter extends HibernateStoreReader implements IHiber
@Override
protected void writeRevision(CDORevision revision)
{
- // do nothing, do it all at commit
+ // Do nothing, do it all at commit
}
@Override
@@ -143,7 +169,7 @@ public class HibernateStoreWriter extends HibernateStoreReader implements IHiber
@Override
protected void writeRevisions(CDORevision[] revisions)
{
- // don't do anything it is done at commit
+ // Don't do anything it is done at commit
}
@Override
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
index 9504424..06b89a0 100644
--- 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
@@ -30,11 +30,13 @@ public class HibernateThreadContext
public static Session getSession()
{
- if (session.get() == null)
+ Session result = session.get();
+ if (result == null)
{
throw new IllegalStateException("Session not set");
}
- return session.get();
+
+ return result;
}
public static void setSession(Session newSession)
@@ -43,24 +45,31 @@ public class HibernateThreadContext
{
throw new IllegalStateException("Session already set");
}
- if (newSession == null)
- {
- TRACER.trace("Clearing session in threadlocal");
- }
- else
+
+ if (TRACER.isEnabled())
{
- TRACER.trace("Setting session in threadlocal");
+ if (newSession == null)
+ {
+ TRACER.trace("Clearing session in threadlocal");
+ }
+ else
+ {
+ TRACER.trace("Setting session in threadlocal");
+ }
}
+
session.set(newSession);
}
public static CommitContext getCommitContext()
{
- if (commitContext.get() == null)
+ CommitContext result = commitContext.get();
+ if (result == null)
{
throw new IllegalStateException("CommitContext not set");
}
- return commitContext.get();
+
+ return result;
}
public static void setCommitContext(CommitContext newCommitContext)
@@ -69,14 +78,19 @@ public class HibernateThreadContext
{
throw new IllegalStateException("CommitContext already set");
}
- if (newCommitContext == null)
- {
- TRACER.trace("Clearing commitcontext in threadlocal");
- }
- else
+
+ if (TRACER.isEnabled())
{
- TRACER.trace("Setting commitcontext in threadlocal");
+ if (newCommitContext == null)
+ {
+ TRACER.trace("Clearing commitcontext in threadlocal");
+ }
+ else
+ {
+ TRACER.trace("Setting commitcontext in threadlocal");
+ }
}
+
commitContext.set(newCommitContext);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
index 536d412..cca7ef1 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
@@ -66,6 +66,7 @@ public class HibernateUtil
throw new IllegalStateException("CDORevision " + cdoRevision.getCDOClass().getName() + " " + cdoRevision.getID()
+ " does not have a hibernate cdoid after saving/updating it");
}
+
return (CDOIDHibernate)cdoRevision.getID();
}
@@ -83,6 +84,7 @@ public class HibernateUtil
return revision;
}
}
+
for (CDORevision revision : commitContext.getDirtyObjects())
{
if (revision.getID().equals(id))
@@ -106,6 +108,7 @@ public class HibernateUtil
throw new IllegalArgumentException("Passed cdoid is not an instance of CDOIDHibernate but a "
+ id.getClass().getName() + ": " + id);
}
+
final CDOIDHibernate cdoIDHibernate = (CDOIDHibernate)id;
final 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/id/CDOIDHibernateImpl.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/id/CDOIDHibernateImpl.java
index f244926..47cff7a 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/id/CDOIDHibernateImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/id/CDOIDHibernateImpl.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.server.hibernate.CDOIDHibernate;
import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -29,6 +30,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.text.MessageFormat;
/**
* @author Eike Stepper
@@ -195,24 +197,31 @@ public class CDOIDHibernateImpl extends AbstractCDOID implements CDOIDHibernate
@Override
public boolean equals(Object obj)
{
- if (!(obj instanceof CDOIDHibernate))
+ if (this == obj)
{
- return false;
+ return true;
}
- return id.equals(((CDOIDHibernate)obj).getId()) && entityName.equals(((CDOIDHibernate)obj).getEntityName());
+ if (obj instanceof CDOIDHibernate)
+ {
+ return ObjectUtil.equals(id, ((CDOIDHibernate)obj).getId())
+ && ObjectUtil.equals(entityName, ((CDOIDHibernate)obj).getEntityName());
+ }
+
+ return false;
}
@Override
public int hashCode()
{
+ // TODO What about entityName?
return id.hashCode();
}
@Override
public String toString()
{
- return getClass().getName() + ": " + entityName + " (id:" + id.toString() + ")";
+ return MessageFormat.format("HBM-{0}-{1}", entityName, id);
}
public static Class<?>[] getClasses()
@@ -220,7 +229,11 @@ public class CDOIDHibernateImpl extends AbstractCDOID implements CDOIDHibernate
return CLASSES;
}
- // used for serialization
+ /**
+ * Used for serialization
+ *
+ * @author Martin Taal
+ */
private static class SerializableContent implements Serializable
{
private static final long serialVersionUID = 1L;
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
index 313c7d9..51b7ae7 100644
--- 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
@@ -29,9 +29,12 @@ import java.sql.Types;
*/
public class CDOIDMetaRangeUserType implements UserType
{
-
private static final int[] SQL_TYPES = { Types.INTEGER, Types.INTEGER };
+ public CDOIDMetaRangeUserType()
+ {
+ }
+
public int[] sqlTypes()
{
return SQL_TYPES;
@@ -47,10 +50,6 @@ public class CDOIDMetaRangeUserType implements UserType
return true;
}
- public CDOIDMetaRangeUserType()
- {
- }
-
public Object deepCopy(Object value)
{
final CDOIDMetaRange cdoRange = (CDOIDMetaRange)value;
@@ -64,10 +63,12 @@ public class CDOIDMetaRangeUserType implements UserType
{
return true;
}
+
if (x == null || y == null)
{
return false;
}
+
return x.equals(y);
}
@@ -79,6 +80,7 @@ public class CDOIDMetaRangeUserType implements UserType
{
return null;
}
+
final CDOIDMeta newCdoIDMeta = new CDOIDMetaImpl(start);
return new CDOIDMetaRangeImpl(newCdoIDMeta, size);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
index 440eee1..483af53 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java
@@ -35,6 +35,7 @@ public class CDOIDPropertyGetter extends CDOPropertyGetter
{
return null;
}
+
final CDOIDHibernate cdoID = (CDOIDHibernate)revision.getID();
if (isVirtualProperty())
{
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
index 406b0f3..67cb4a5 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java
@@ -42,6 +42,7 @@ public class CDOIDPropertySetter extends CDOPropertySetter
{
return;
}
+
final InternalCDORevision revision = (InternalCDORevision)target;
final CDOID cdoID = revision.getID();
if (cdoID == null)
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
index 319d28e..5d79667 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java
@@ -31,7 +31,9 @@ import java.sql.Types;
*/
public class CDOIDUserType implements UserType
{
- // Second varchar is just for informational purposes
+ /**
+ * Second varchar is just for informational purposes
+ */
private static final int[] SQL_TYPES = { Types.VARCHAR, Types.VARCHAR, Types.VARBINARY };
public CDOIDUserType()
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
index c8169bd..4647fd2 100644
--- 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
@@ -48,14 +48,14 @@ public class CDOManyReferenceGetter extends CDOPropertyGetter
@Override
public Object get(Object target) throws HibernateException
{
- // check if there is already a persistentcollection
+ // Check if there is already a persistentcollection
final PersistentCollection collection = PersistableListHolder.getInstance().getListMapping(target, getCDOFeature());
if (collection != null)
{
return collection;
}
- // not yet, get the moveablearraylist
+ // Not yet, get the moveablearraylist
@SuppressWarnings("unchecked")
MoveableArrayList<Object> list = (MoveableArrayList<Object>)super.get(target);
if (list == null)
@@ -66,11 +66,11 @@ public class CDOManyReferenceGetter extends CDOPropertyGetter
revision.setValue(getCDOFeature(), list);
}
- // wrap the moveablearraylist
+ // Wrap the moveablearraylist
final HibernateMoveableListWrapper wrapper = new HibernateMoveableListWrapper();
wrapper.setDelegate(list);
- // and return it
+ // 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
index 8f57dac..6e4f178 100644
--- 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
@@ -30,13 +30,13 @@ public class CDOManyReferenceSetter extends CDOPropertySetter
@Override
public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
{
- // do some checking
+ // 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
+ // 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
index 44c680e..a38c570 100644
--- 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
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionPropertyAccessor.CDORevisionSetter;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
@@ -20,6 +21,8 @@ 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
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
index ee88765..1a24e61 100644
--- 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
@@ -20,14 +20,14 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
*/
public abstract class CDOPropertyHandler
{
+ private final ContextTracer tracer = new ContextTracer(OM.DEBUG, this.getClass());
+
private CDORevisionTuplizer tuplizer;
private CDOFeature cdoFeature;
private boolean virtualProperty = false;
- private final ContextTracer tracer = new ContextTracer(OM.DEBUG, this.getClass());
-
public CDOPropertyHandler(CDORevisionTuplizer tuplizer, String propertyName)
{
this.tuplizer = tuplizer;
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
index d0c7578..17cb90c 100644
--- 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
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionPropertyAccessor.CDORevisionSetter;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -19,6 +20,8 @@ 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
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
index d338a24..813119e 100644
--- 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
@@ -35,6 +35,7 @@ public class CDOReferenceGetter extends CDOPropertyGetter
{
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/CDORevisionTuplizer.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
index 423b357..6c8832c 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
@@ -44,7 +44,11 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
public CDORevisionTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
{
super(entityMetamodel, mappingInfo);
- TRACER.trace("Created CDORevisionTuplizer for entity " + mappingInfo.getEntityName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Created CDORevisionTuplizer for entity " + mappingInfo.getEntityName());
+ }
+
initCDOClass(mappingInfo);
}
@@ -54,6 +58,7 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
{
return;
}
+
final HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
// find the CDOClass/Package
@@ -62,7 +67,10 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
final String entityName = mappingInfo.getEntityName();
final String ePackageURI = mappingInfo.getMetaAttribute("epackage").getValue();
- TRACER.trace("EntityName/packageURI " + entityName + " " + ePackageURI);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("EntityName/packageURI " + entityName + " " + ePackageURI);
+ }
for (CDOPackage cdoPackage : hbStore.getPackageHandler().getCDOPackages())
{
@@ -70,6 +78,7 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
{
continue;
}
+
for (CDOClass localCdoClass : cdoPackage.getClasses())
{
if (localCdoClass.getName().compareTo(entityName) == 0)
@@ -79,6 +88,7 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
}
}
}
+
if (cdoClass == null && ePackageURI.compareTo(CDOResourcePackage.PACKAGE_URI) == 0)
{
for (CDOClass localCdoClass : hbStore.getRepository().getPackageManager().getCDOResourcePackage().getClasses())
@@ -86,7 +96,11 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
if (localCdoClass.getName().compareTo(entityName) == 0)
{
cdoClass = localCdoClass;
- TRACER.trace("Class is CDOResource class");
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Class is CDOResource class");
+ }
+
break;
}
}
@@ -170,8 +184,10 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity)
{
initCDOClass(mappedEntity);
-
- TRACER.trace("Building property getter for " + cdoClass.getName() + "." + mappedProperty.getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Building property getter for " + cdoClass.getName() + "." + mappedProperty.getName());
+ }
if (mappedProperty.isBackRef())
{
@@ -185,30 +201,28 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
{
return new CDOVersionPropertyGetter(this, mappedProperty.getName());
}
- else
+
+ final CDOFeature cdoFeature = getCDOClass().lookupFeature(mappedProperty.getName());
+ if (cdoFeature.isReference() && cdoFeature.isMany())
{
- final 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());
- }
- else
- {
- return new CDOPropertyGetter(this, mappedProperty.getName());
- }
+ 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);
-
- TRACER.trace("Building property setter for " + cdoClass.getName() + "." + mappedProperty.getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Building property setter for " + cdoClass.getName() + "." + mappedProperty.getName());
+ }
if (mappedProperty.isBackRef())
{
@@ -222,22 +236,18 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
{
return new CDOVersionPropertySetter(this, mappedProperty.getName());
}
- else
+
+ final CDOFeature cdoFeature = getCDOClass().lookupFeature(mappedProperty.getName());
+ if (cdoFeature.isReference() && cdoFeature.isMany())
{
- final 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());
- }
- else
- {
- return new CDOPropertySetter(this, mappedProperty.getName());
- }
+ return new CDOManyReferenceSetter(this, mappedProperty.getName());
+ }
+ else if (cdoFeature.isReference())
+ {
+ return new CDOReferenceSetter(this, mappedProperty.getName());
}
+
+ return new CDOPropertySetter(this, mappedProperty.getName());
}
@Override
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
index 979f17b..d221953 100644
--- 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
@@ -27,7 +27,6 @@ import java.sql.Types;
*/
public class CDOTypeUserType implements UserType
{
-
private static final int[] SQL_TYPES = { Types.INTEGER };
public int[] sqlTypes()
@@ -60,10 +59,12 @@ public class CDOTypeUserType implements UserType
{
return true;
}
+
if (x == null || y == null)
{
return false;
}
+
return x.equals(y);
}
@@ -74,10 +75,12 @@ public class CDOTypeUserType implements UserType
{
return null;
}
+
if (value == null)
{
return null;
}
+
return CDOTypeImpl.index.get(value);
}
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
index e928f55..f766090 100644
--- 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
@@ -34,13 +34,11 @@ public class CDOVersionPropertyGetter extends CDOPropertyGetter
{
return revision.getVersion();
}
- else
- {
- final Object version = super.get(target);
- // TODO: does this make sense?
- // revision.setVersion(((Number)value).intValue());
- return version;
- }
+
+ final Object version = super.get(target);
+ // TODO: does this make sense?
+ // revision.setVersion(((Number)value).intValue());
+ return version;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
index f94bfae..75037e8 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java
@@ -31,6 +31,10 @@ public class HibernateMoveableListWrapper implements List<Object>
{
private MoveableArrayList<Object> delegate;
+ public HibernateMoveableListWrapper()
+ {
+ }
+
/**
* @return the delegate
*/
@@ -71,6 +75,7 @@ public class HibernateMoveableListWrapper implements List<Object>
{
result.add(getObject(o));
}
+
return result;
}
@@ -87,6 +92,7 @@ public class HibernateMoveableListWrapper implements List<Object>
{
newC.add(getCDOID(o));
}
+
return newC;
}
@@ -203,6 +209,7 @@ public class HibernateMoveableListWrapper implements List<Object>
{
result[i++] = o;
}
+
return result;
}
@@ -214,14 +221,15 @@ public class HibernateMoveableListWrapper implements List<Object>
{
a[i++] = (T)o;
}
+
return a;
}
- private static class CDOHibernateIterator implements Iterator<Object>
+ private static final class CDOHibernateIterator implements Iterator<Object>
{
- final Iterator<?> delegate;
+ private final Iterator<?> delegate;
- CDOHibernateIterator(Iterator<?> delegate)
+ public CDOHibernateIterator(Iterator<?> delegate)
{
this.delegate = delegate;
}
@@ -233,11 +241,12 @@ public class HibernateMoveableListWrapper implements List<Object>
public Object next()
{
- final Object o = this.delegate.next();
+ final Object o = delegate.next();
if (o instanceof CDOID)
{
return HibernateUtil.getInstance().getCDORevision((CDOID)o);
}
+
return o;
}
@@ -247,11 +256,11 @@ public class HibernateMoveableListWrapper implements List<Object>
}
}
- private class CDOHibernateListIterator implements ListIterator<Object>
+ private static final class CDOHibernateListIterator implements ListIterator<Object>
{
- final ListIterator<Object> delegate;
+ private final ListIterator<Object> delegate;
- CDOHibernateListIterator(ListIterator<Object> delegate)
+ public CDOHibernateListIterator(ListIterator<Object> delegate)
{
this.delegate = delegate;
}
@@ -273,11 +282,12 @@ public class HibernateMoveableListWrapper implements List<Object>
public Object next()
{
- final Object o = this.delegate.next();
+ final Object o = delegate.next();
if (o instanceof CDOID)
{
return HibernateUtil.getInstance().getCDORevision((CDOID)delegate.next());
}
+
return o;
}
@@ -288,11 +298,12 @@ public class HibernateMoveableListWrapper implements List<Object>
public Object previous()
{
- final Object o = this.delegate.previous();
+ final Object o = delegate.previous();
if (o instanceof CDOID)
{
return HibernateUtil.getInstance().getCDORevision((CDOID)delegate.next());
}
+
return o;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
index 91962e8..aa904cd 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java
@@ -27,31 +27,27 @@ import java.util.Map;
*
* @author Martin Taal
*/
-
public class PersistableListHolder
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, PersistableListHolder.class);
private static PersistableListHolder instance = new PersistableListHolder();
- public static PersistableListHolder getInstance()
- {
- return instance;
- }
+ private ThreadLocal<Map<Key, PersistentCollection>> listMapping = new ThreadLocal<Map<Key, PersistentCollection>>();
- public static void setInstance(PersistableListHolder instance)
+ public PersistableListHolder()
{
- PersistableListHolder.instance = instance;
}
- private ThreadLocal<Map<Key, PersistentCollection>> listMapping = new ThreadLocal<Map<Key, PersistentCollection>>();
-
public void putListMapping(Object target, CDOFeature cdoFeature, PersistentCollection collection)
{
final Key key = new Key(target, cdoFeature);
getListMapping().put(key, collection);
- TRACER.trace("Stored hb list in threadlocal: " + ((CDORevision)target).getCDOClass().getName() + "."
- + cdoFeature.getName());
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Stored hb list in threadlocal: " + ((CDORevision)target).getCDOClass().getName() + "."
+ + cdoFeature.getName());
+ }
}
public PersistentCollection getListMapping(Object target, CDOFeature cdoFeature)
@@ -66,16 +62,27 @@ public class PersistableListHolder
{
listMapping.set(new HashMap<Key, PersistentCollection>());
}
+
return listMapping.get();
}
- private class Key
+ 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;
- Key(Object owner, CDOFeature cdoFeature)
+ public Key(Object owner, CDOFeature cdoFeature)
{
this.owner = owner;
this.cdoFeature = cdoFeature;
@@ -88,6 +95,7 @@ public class PersistableListHolder
{
return false;
}
+
final Key otherKey = (Key)obj;
// the owner is uniquely present in mem, the same applies for the cdoFeature
// therefore == is allowed
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
index e753757..ec430f5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import java.util.HashMap;
import java.util.Map;
@@ -29,6 +30,8 @@ public abstract class Store extends Lifecycle implements IStore
{
private String type;
+ // Exclude from dump due to contained db password
+ @ExcludeFromDump
private Map<String, String> properties;
private IRepository repository;
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java
index e092db5..dece29f 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java
@@ -123,13 +123,13 @@ public class HibernateTest extends AbstractOMTest
props.setProperty(Environment.DRIVER, driverName);
props.setProperty(Environment.URL, "jdbc:mysql://localhost/cdohibernate");
props.setProperty(Environment.USER, "root");
- // props.setProperty(Environment.PASS, "root");
+ props.setProperty(Environment.PASS, "root");
props.setProperty(Environment.DIALECT, dialectName);
props.setProperty(Environment.SHOW_SQL, "true");
props.setProperty("hibernate.hbm2ddl.auto", "create-drop");
// IHibernateMappingProvider mappingProvider = new TeneoHibernateMappingProvider();
// return new HibernateStore(props, mappingProvider);
- return new HibernateStore(props, null);
+ return new HibernateStore(null, props);
}
private static EObject getInputModel()