Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2011-10-24 10:58:12 +0000
committerMartin Taal2011-10-24 10:58:12 +0000
commit2afc318a7b9ca4337fca7e73b3b006c960140a52 (patch)
tree526672363637153e8842c05c52be97d4d5a3a865 /plugins/org.eclipse.emf.cdo.server.hibernate
parent519358316aab95877bdd6596bb47d6c1c56c6d84 (diff)
downloadcdo-2afc318a7b9ca4337fca7e73b3b006c960140a52.tar.gz
cdo-2afc318a7b9ca4337fca7e73b3b006c960140a52.tar.xz
cdo-2afc318a7b9ca4337fca7e73b3b006c960140a52.zip
[361792] store commit time stamp in the database
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/.settings/.api_filters32
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateBranchPointImpl.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateConstants.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampGetter.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampSetter.java56
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java9
7 files changed, 167 insertions, 12 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/.api_filters
index b2ad589455..2bf9014e4f 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/.api_filters
@@ -1,12 +1,20 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.emf.cdo.server.hibernate" version="2">
- <resource path="src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java" type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.WrappedHibernateList">
- <filter id="574660632">
- <message_arguments>
- <message_argument value="InternalCDOList"/>
- <message_argument value="CDOList"/>
- <message_argument value="WrappedHibernateList"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.emf.cdo.server.hibernate" version="2">
+ <resource path="src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateBranchPointImpl.java" type="org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateBranchPointImpl">
+ <filter comment="Need to implement own version of branch point to store commit information" id="574619656">
+ <message_arguments>
+ <message_argument value="CDOBranchPoint"/>
+ <message_argument value="CDOHibernateBranchPointImpl"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java" type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.WrappedHibernateList">
+ <filter id="574660632">
+ <message_arguments>
+ <message_argument value="InternalCDOList"/>
+ <message_argument value="CDOList"/>
+ <message_argument value="WrappedHibernateList"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateBranchPointImpl.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateBranchPointImpl.java
new file mode 100644
index 0000000000..87505f39de
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateBranchPointImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011 Eike Stepper (Berlin, 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:
+ * Martin Taal
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate;
+
+import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOBranchTimeStampGetter;
+import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOBranchTimeStampSetter;
+
+/**
+ * Used to get the timestamp from the db into the revision branchpoint.
+ *
+ * @see CDOBranchTimeStampGetter
+ * @see CDOBranchTimeStampSetter
+ * @author Martin Taal
+ */
+@SuppressWarnings("restriction")
+public class CDOHibernateBranchPointImpl extends CDOBranchPointImpl
+{
+
+ public CDOHibernateBranchPointImpl(long timeStamp)
+ {
+ super(HibernateThreadContext.getCurrentStoreAccessor().getStore().getRepository().getBranchManager()
+ .getMainBranch(), timeStamp);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateConstants.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateConstants.java
index b6646b82c0..5f61b83427 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateConstants.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/CDOHibernateConstants.java
@@ -20,6 +20,8 @@ public class CDOHibernateConstants
{
public static final String ID_PROPERTY = "id"; //$NON-NLS-1$
+ public static final String COMMITTIMESTAMP_PROPERTY = "commit_TimeStamp"; //$NON-NLS-1$
+
public static final String RESOURCE_PROPERTY = "resourceID"; //$NON-NLS-1$
public static final String RESOURCE_PROPERTY_COLUMN = "resource_id"; //$NON-NLS-1$
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 df5e3cd7de..b647ccce59 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
@@ -699,6 +699,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
try
{
final CDORevision revision = HibernateUtil.getInstance().getCDORevision(id);
+
// maybe deleted in parallell?
if (revision != null)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampGetter.java
new file mode 100644
index 0000000000..da7d49fba7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampGetter.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Eike Stepper (Berlin, 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:
+ * Martin Taal
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateBranchPointImpl;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Gets the time stamp value to store in the database.
+ *
+ * @see CDOHibernateBranchPointImpl
+ * @author Martin Taal
+ */
+public class CDOBranchTimeStampGetter extends CDOPropertyGetter
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOBranchTimeStampGetter(CDORevisionTuplizer tuplizer, String propertyName)
+ {
+ super(tuplizer, propertyName);
+ }
+
+ @Override
+ public Object get(Object target) throws HibernateException
+ {
+ final InternalCDORevision revision = (InternalCDORevision)target;
+ final Object value = revision.getTimeStamp();
+ return value;
+ }
+
+ @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/CDOBranchTimeStampSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampSetter.java
new file mode 100644
index 0000000000..39effb161c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOBranchTimeStampSetter.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Eike Stepper (Berlin, 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:
+ * Martin Taal
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateBranchPointImpl;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * Sets the time stamp information in the revision.
+ *
+ * @see CDOHibernateBranchPointImpl
+ * @author Martin Taal
+ */
+public class CDOBranchTimeStampSetter extends CDOPropertySetter
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOBranchTimeStampSetter(CDORevisionTuplizer tuplizer, String propertyName)
+ {
+ super(tuplizer, propertyName);
+ }
+
+ @Override
+ public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
+ {
+ final InternalCDORevision revision = (InternalCDORevision)target;
+ final long timeStamp;
+ if (value == null)
+ {
+ timeStamp = 0;
+ }
+ else
+ {
+ timeStamp = (Long)value;
+ }
+ final CDOHibernateBranchPointImpl branchPoint = new CDOHibernateBranchPointImpl(timeStamp);
+ revision.setBranchPoint(branchPoint);
+ }
+
+ @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/CDORevisionTuplizer.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java
index db07d4fcc0..e1448589aa 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
@@ -210,6 +210,10 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
{
return new CDOContainerGetter(this, mappedProperty.getName());
}
+ else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0)
+ {
+ return new CDOBranchTimeStampGetter(this, mappedProperty.getName());
+ }
EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName());
if (feature instanceof EReference && feature.isMany())
@@ -263,6 +267,11 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
return new CDOContainerSetter(this, mappedProperty.getName());
}
+ if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0)
+ {
+ return new CDOBranchTimeStampSetter(this, mappedProperty.getName());
+ }
+
EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName());
if (feature instanceof EReference && feature.isMany())
{

Back to the top