Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2011-05-11 18:25:01 +0000
committerMartin Taal2011-05-11 18:25:01 +0000
commite385b86be5b9ef76d71c6996a0a58e22925fe600 (patch)
treea7441be81c4607d98fc785ade604bd5b2b60fac2 /plugins/org.eclipse.emf.cdo.server.hibernate
parent15fbd5d81a9f7173ca5c3c1476d729471f1d0ad3 (diff)
downloadcdo-e385b86be5b9ef76d71c6996a0a58e22925fe600.tar.gz
cdo-e385b86be5b9ef76d71c6996a0a58e22925fe600.tar.xz
cdo-e385b86be5b9ef76d71c6996a0a58e22925fe600.zip
Fixes bugzilla 330164 - [Hibernate] Upgrade to Hibernate 3.6.0
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java82
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyGetter.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionPropertyAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxyFactory.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionTuplizer.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticVersionPropertyHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryFeatureURIPropertyHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryPropertyHandler.java6
9 files changed, 123 insertions, 14 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
index 2c30a33382..6b11f99fb8 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
@@ -50,7 +50,13 @@ import org.eclipse.core.runtime.Platform;
import org.hibernate.Session;
import org.hibernate.proxy.HibernateProxy;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
import java.util.Map;
import java.util.Properties;
@@ -73,23 +79,29 @@ public class HibernateUtil
private static final String CLASS = "class"; //$NON-NLS-1$
- /**
- * @return the global singleton instance
- */
- public static HibernateUtil getInstance()
+ // Local copy of the datatype factory
+ private DatatypeFactory dataTypeFactory;
+
+ public HibernateUtil()
{
- return instance;
+ try
+ {
+ dataTypeFactory = DatatypeFactory.newInstance();
+ }
+ catch (DatatypeConfigurationException ex)
+ {
+ throw new IllegalStateException("Exception ", ex);
+ }
}
- /**
- * Sets the singleton used by the Hibernate store.
- *
- * @param instance
- * the instance to set
- */
- public static void setInstance(HibernateUtil instance)
+ public DatatypeFactory getDataTypeFactory()
{
- HibernateUtil.instance = instance;
+ return dataTypeFactory;
+ }
+
+ public void setDataTypeFactory(DatatypeFactory dataTypeFactory)
+ {
+ this.dataTypeFactory = dataTypeFactory;
}
/**
@@ -623,4 +635,48 @@ public class HibernateUtil
final HibernateStoreAccessor accessor = HibernateThreadContext.getCurrentStoreAccessor();
return accessor.getStore().getEntityName(classifierRef);
}
+
+ /**
+ * Create a {@link XMLGregorianCalendar} from a {@link Date} instance.
+ */
+ public XMLGregorianCalendar getXMLGregorianCalendarDate(Date date, boolean dateTime)
+ {
+ final XMLGregorianCalendar gregCalendar = dataTypeFactory.newXMLGregorianCalendar();
+ final Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ gregCalendar.setYear(calendar.get(Calendar.YEAR));
+ gregCalendar.setMonth(calendar.get(Calendar.MONTH) + 1); // correct with 1 on purpose
+ gregCalendar.setDay(calendar.get(Calendar.DAY_OF_MONTH));
+
+ if (dateTime)
+ {
+ gregCalendar.setHour(calendar.get(Calendar.HOUR_OF_DAY));
+ gregCalendar.setMinute(calendar.get(Calendar.MINUTE));
+ gregCalendar.setSecond(calendar.get(Calendar.SECOND));
+ gregCalendar.setMillisecond(calendar.get(Calendar.MILLISECOND));
+ }
+
+ return gregCalendar;
+ }
+
+ /**
+ * @return the global singleton instance
+ */
+ public static HibernateUtil getInstance()
+ {
+ return instance;
+ }
+
+ /**
+ * Sets the singleton used by the Hibernate store.
+ *
+ * @param instance
+ * the instance to set
+ */
+ public static void setInstance(HibernateUtil instance)
+ {
+ HibernateUtil.instance = instance;
+ }
+
}
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 c34169ff8d..2b0c13b46a 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
@@ -22,6 +22,7 @@ import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.property.Getter;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Map;
@@ -123,6 +124,11 @@ public class CDOPropertyGetter extends CDOPropertyHandler implements Getter
return null;
}
+ public Member getMember()
+ {
+ return null;
+ }
+
@SuppressWarnings("rawtypes")
public Class getReturnType()
{
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
index f12f000a04..46bceba46c 100644
--- 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
@@ -22,6 +22,7 @@ import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.Setter;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Map;
@@ -123,6 +124,11 @@ public class CDORevisionPropertyAccessor implements PropertyAccessor
{
return Object.class;
}
+
+ public Member getMember()
+ {
+ return null;
+ }
}
/**
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
index f696fbf7ee..1bc27af673 100644
--- 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
@@ -15,6 +15,7 @@ import org.hibernate.engine.SessionImplementor;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.ProxyFactory;
import org.hibernate.type.AbstractComponentType;
+import org.hibernate.type.CompositeType;
import java.io.Serializable;
import java.lang.reflect.Method;
@@ -42,4 +43,19 @@ public class CDORevisionProxyFactory implements ProxyFactory
{
return new CDORevisionProxyHibernate(new CDORevisionLazyInitializer(entityName, id, session));
}
+
+ public void postInstantiate(String arg0, Class arg1, Set arg2, Method arg3, Method arg4, CompositeType arg5)
+ throws HibernateException
+ {
+ }
+
+ public String getEntityName()
+ {
+ return entityName;
+ }
+
+ public void setEntityName(String entityName)
+ {
+ this.entityName = entityName;
+ }
}
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 b625f587f2..9deaa6ffc7 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
@@ -294,7 +294,8 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer
@Override
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter)
{
- ProxyFactory pf = new CDORevisionProxyFactory();
+ CDORevisionProxyFactory pf = new CDORevisionProxyFactory();
+ pf.setEntityName(getEntityName());
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
index a94b2ebd0f..b95498c2f6 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOSyntheticIdPropertyHandler.java
@@ -28,6 +28,7 @@ import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.Setter;
import java.io.Serializable;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Map;
@@ -52,6 +53,11 @@ public class CDOSyntheticIdPropertyHandler implements Getter, Setter, PropertyAc
return this;
}
+ public Member getMember()
+ {
+ return null;
+ }
+
public Object get(Object owner) throws HibernateException
{
InternalCDORevision revision = HibernateUtil.getInstance().getCDORevision(owner);
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
index 3127ee2097..ef3f9ab31c 100644
--- 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
@@ -22,6 +22,7 @@ import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.Setter;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Map;
@@ -75,6 +76,11 @@ public class CDOSyntheticVersionPropertyHandler implements Getter, Setter, Prope
return null;
}
+ public Member getMember()
+ {
+ return null;
+ }
+
public String getMethodName()
{
return null;
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryFeatureURIPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryFeatureURIPropertyHandler.java
index 7faccef38a..079f8ebed2 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryFeatureURIPropertyHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryFeatureURIPropertyHandler.java
@@ -27,6 +27,7 @@ import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.Setter;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Map;
@@ -54,6 +55,11 @@ public class FeatureMapEntryFeatureURIPropertyHandler implements PropertyAccesso
return this;
}
+ public Member getMember()
+ {
+ return null;
+ }
+
public Object get(Object owner) throws HibernateException
{
final CDOFeatureMapEntry cdoFeatureMapEntry = (CDOFeatureMapEntry)owner;
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryPropertyHandler.java
index 0d6c77eeaf..0bd8b224c8 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryPropertyHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryPropertyHandler.java
@@ -21,6 +21,7 @@ import org.hibernate.property.Getter;
import org.hibernate.property.PropertyAccessor;
import org.hibernate.property.Setter;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.Map;
@@ -49,6 +50,11 @@ public class FeatureMapEntryPropertyHandler implements PropertyAccessor, Getter,
return this;
}
+ public Member getMember()
+ {
+ return null;
+ }
+
public String getPropertyName()
{
return propertyName;

Back to the top