summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-02-25 10:15:44 (EST)
committerEike Stepper2008-02-25 10:15:44 (EST)
commit893709d5ffb6401033aa74a3ed95587aa83d56ca (patch)
tree7de1b6150d939322f4d874e5025ab8a8c908b7e2
parent1b1facdb792c5e0534f22cba2c16e7234ed11bec (diff)
downloadcdo-893709d5ffb6401033aa74a3ed95587aa83d56ca.zip
cdo-893709d5ffb6401033aa74a3ed95587aa83d56ca.tar.gz
cdo-893709d5ffb6401033aa74a3ed95587aa83d56ca.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/src/org/eclipse/emf/cdo/server/internal/hibernate/id/CDOIDHibernateImpl.java63
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDUserType.java18
2 files changed, 42 insertions, 39 deletions
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 64f88c2..f244926 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,7 +18,6 @@ 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.HexUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -39,10 +38,10 @@ public class CDOIDHibernateImpl extends AbstractCDOID implements CDOIDHibernate
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOIDHibernateImpl.class);
- private static final long serialVersionUID = 1L;
-
private static final Class<?>[] CLASSES = { CDOIDHibernateImpl.class, Legacy.class, SerializableContent.class };
+ private static final long serialVersionUID = 1L;
+
private Serializable id;
private String entityName;
@@ -102,49 +101,49 @@ public class CDOIDHibernateImpl extends AbstractCDOID implements CDOIDHibernate
public void read(ExtendedDataInput in) throws IOException
{
- // id = (Serializable)in.readObject();
- // if (TRACER.isEnabled())
- // {
- // TRACER.format("Read id={0}", id);
- // }
- //
- // entityName = in.readString();
- // if (TRACER.isEnabled())
- // {
- // TRACER.format("Read entityName={0}", entityName);
- // }
-
- final byte[] content = in.readByteArray();
+ id = (Serializable)in.readObject();
if (TRACER.isEnabled())
{
- TRACER.format("Read content={0}", HexUtil.bytesToHex(content));
+ TRACER.format("Read id={0}", id);
}
- setContent(content);
- }
+ entityName = in.readString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read entityName={0}", entityName);
+ }
- public void write(ExtendedDataOutput out) throws IOException
- {
- // if (TRACER.isEnabled())
- // {
- // TRACER.format("Writing id={0}", id);
- // }
- //
- // out.writeObject(id);
+ // final byte[] content = in.readByteArray();
// if (TRACER.isEnabled())
// {
- // TRACER.format("Writing entityName={0}", entityName);
+ // TRACER.format("Read content={0}", HexUtil.bytesToHex(content));
// }
//
- // out.writeString(entityName);
+ // setContent(content);
+ }
- byte[] content = getContent();
+ public void write(ExtendedDataOutput out) throws IOException
+ {
if (TRACER.isEnabled())
{
- TRACER.format("Writing content={0}", HexUtil.bytesToHex(content));
+ TRACER.format("Writing id={0}", id);
}
- out.writeByteArray(content);
+ out.writeObject(id);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing entityName={0}", entityName);
+ }
+
+ out.writeString(entityName);
+
+ // byte[] content = getContent();
+ // if (TRACER.isEnabled())
+ // {
+ // TRACER.format("Writing content={0}", HexUtil.bytesToHex(content));
+ // }
+ //
+ // out.writeByteArray(content);
}
public byte[] getContent()
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 e5a497d..319d28e 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
@@ -27,14 +27,17 @@ import java.sql.SQLException;
import java.sql.Types;
/**
- * Persists a cdoid in the db.
+ * Persists a CDOID in the DB.
*/
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()
+ {
+ }
+
public int[] sqlTypes()
{
return SQL_TYPES;
@@ -50,10 +53,6 @@ public class CDOIDUserType implements UserType
return false;
}
- public CDOIDUserType()
- {
- }
-
public Object deepCopy(Object value)
{
return value;
@@ -65,10 +64,12 @@ public class CDOIDUserType implements UserType
{
return true;
}
+
if (x == null || y == null)
{
return false;
}
+
return x.equals(y);
}
@@ -79,6 +80,7 @@ public class CDOIDUserType implements UserType
{
return null;
}
+
final byte[] content = (byte[])Hibernate.BINARY.nullSafeGet(rs, names[2]);
final CDOIDHibernate cdoID = new CDOIDHibernateImpl();
cdoID.setContent(content);
@@ -93,6 +95,7 @@ public class CDOIDUserType implements UserType
statement.setNull(index, Types.VARCHAR);
statement.setNull(index, Types.VARBINARY);
}
+
if (value != null)
{
final CDOIDHibernate cdoID;
@@ -108,6 +111,7 @@ public class CDOIDUserType implements UserType
{
cdoID = (CDOIDHibernate)value;
}
+
statement.setString(index, cdoID.getEntityName());
statement.setString(index + 1, cdoID.getId().toString());
statement.setBytes(index + 2, cdoID.getContent());