summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-02-23 03:36:49 (EST)
committerEike Stepper2008-02-23 03:36:49 (EST)
commit6d074e987d10c5117fdd496653bf589402f4ee5c (patch)
tree234417286ba6b746c1c8ff1ae2790efd9382ceae
parentc5a3c052177759f9be3d6694bf16f591ba98208a (diff)
downloadcdo-6d074e987d10c5117fdd496653bf589402f4ee5c.zip
cdo-6d074e987d10c5117fdd496653bf589402f4ee5c.tar.gz
cdo-6d074e987d10c5117fdd496653bf589402f4ee5c.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.teneo/.cvsignore3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOTeneoException.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/TeneoHibernateMappingProvider.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/build.properties8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/HibernateUtil.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java209
9 files changed, 139 insertions, 118 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.cvsignore b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.cvsignore
new file mode 100644
index 0000000..e59ed82
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.cvsignore
@@ -0,0 +1,3 @@
+bin
+doc
+*.jar
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.settings/org.eclipse.jdt.core.prefs
index 2b7f713..b7c3f44 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Sat Feb 23 08:26:13 CET 2008
+#Sat Feb 23 09:30:14 CET 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOTeneoException.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOTeneoException.java
index 0374c1b..9bde9e2 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOTeneoException.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/CDOTeneoException.java
@@ -15,11 +15,13 @@ package org.eclipse.emf.cdo.server.hibernate.teneo;
*
* @author Martin Taal
*/
-public class CDOTeneoException extends RuntimeException {
+public class CDOTeneoException extends RuntimeException
+{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public CDOTeneoException(String msg, Throwable cause) {
- super(msg, cause);
- }
+ public CDOTeneoException(String msg, Throwable cause)
+ {
+ super(msg, cause);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/TeneoHibernateMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/TeneoHibernateMappingProvider.java
index 758372c..65a07bb 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/TeneoHibernateMappingProvider.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/teneo/TeneoHibernateMappingProvider.java
@@ -10,14 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.hibernate.teneo;
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
+
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
@@ -30,6 +24,13 @@ import org.eclipse.emf.teneo.extension.ExtensionUtil;
import org.eclipse.emf.teneo.hibernate.mapper.MappingContext;
import org.eclipse.emf.teneo.hibernate.mapper.MappingUtil;
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
/**
* Handles different cases of input modes: the modelObjects can be a collection of String (containing an ecore model) or
* EPackage objects.
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/org.eclipse.jdt.core.prefs
index 188aa3a..b7c3f44 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Sat Feb 23 08:45:21 CET 2008
+#Sat Feb 23 09:30:14 CET 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/build.properties b/plugins/org.eclipse.emf.cdo.server.hibernate/build.properties
index e3ed708..64d5699 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/build.properties
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/build.properties
@@ -22,7 +22,13 @@ bin.includes = META-INF/,\
plugin.properties,\
mappings/,\
src/log4j.properties,\
- lib/
+ lib/asm.jar,\
+ lib/cglib-2.1.3.jar,\
+ lib/changelog.txt,\
+ lib/commons-collections-2.1.1.jar,\
+ lib/jta.jar,\
+ lib/lgpl.txt,\
+ lib/readme.txt
jars.extra.classpath = platform:/plugin/org.eclipse.emf.teneo.hibernate.mapper/dom4j-1.6.1.jar,\
platform:/plugin/org.eclipse.emf.teneo.hibernate.mapper/hibernate3.jar,\
platform:/plugin/org.eclipse.emf.teneo.libraries/commons-logging.jar
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/HibernateUtil.java
index 2c32959..ee5c741 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/HibernateUtil.java
@@ -11,10 +11,10 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.hibernate;
-import java.util.Properties;
-
import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
+import java.util.Properties;
+
/**
* @author Eike Stepper
* @author Martin Taal
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.jdt.core.prefs
index 85dc5b8..ae782dd 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Sun Jan 07 14:27:04 CET 2007
+#Sat Feb 23 09:30:14 CET 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
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 f833893..cdc9766 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
@@ -10,13 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.tests.hibernate;
-import java.io.PrintWriter;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.server.CDOServerUtil;
@@ -29,8 +22,7 @@ import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.cdo.tests.model1.Product;
import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
+
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.internal.util.om.log.PrintLogHandler;
@@ -39,101 +31,118 @@ import org.eclipse.net4j.jvm.JVMUtil;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.om.OMPlatform;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.MySQLInnoDBDialect;
+import java.io.PrintWriter;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
/**
* @author Eike Stepper
*/
-public class HibernateTest {
- private static final String REPOSITORY_NAME = "repo1";
-
- public static void main(String[] args) throws Exception {
- IManagedContainer container = initContainer();
-
- // Start the transport and create a repository
- JVMUtil.getAcceptor(container, "default"); // Start the JVM transport
- CDOServerUtil.addRepository(container, createRepository()); // Start a CDO respository
-
- // Establish a communications connection and open a session with the repository
- IConnector connector = JVMUtil.getConnector(container, "default"); // Open a JVM connection
- CDOSession session = CDOUtil.openSession(connector, REPOSITORY_NAME, true);// Open a CDO
- // session
- session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);// Not needed after
- // first
- // commit!!!
-
- // Open a transaction, and create a new resource
- CDOTransaction transaction = session.openTransaction();
- Resource resource = transaction.createResource("/my/big/resource");
- resource.getContents().add(getInputModel());
- transaction.commit();
-
- // Cleanup
- session.close();
- connector.disconnect();
- }
-
- private static IManagedContainer initContainer() {
- // Turn on tracing
- OMPlatform.INSTANCE.setDebugging(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
-
- // Prepare the standalone infra structure (not needed when running inside Eclipse)
- IManagedContainer container = ContainerUtil.createContainer(); // Create a wiring container
- Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
- JVMUtil.prepareContainer(container); // Prepare the JVM transport
- CDOServerUtil.prepareContainer(container); // Prepare the CDO server
- CDOUtil.prepareContainer(container, false); // Prepare the CDO client
- return container;
- }
-
- private static IRepository createRepository() throws Exception {
- Map<String, String> props = new HashMap<String, String>();
- props.put(Props.PROP_SUPPORTING_AUDITS, "false");
- props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "false");
- props.put(Props.PROP_VERIFYING_REVISIONS, "false");
- props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
- props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
- return CDOServerUtil.createRepository(REPOSITORY_NAME, createStore(), props);
- }
-
- private static IStore createStore() throws Exception {
- DriverManager.setLogWriter(new PrintWriter(System.out));
- Driver driver = new com.mysql.jdbc.Driver();
- DriverManager.registerDriver(driver);
- String driverName = driver.getClass().getName();
- String dialectName = MySQLInnoDBDialect.class.getName();
-
- Properties props = new Properties();
- 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.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);
- }
-
- private static EObject getInputModel() {
- Category cat1 = Model1Factory.eINSTANCE.createCategory();
- cat1.setName("CAT1");
- Category cat2 = Model1Factory.eINSTANCE.createCategory();
- cat2.setName("CAT2");
- cat1.getCategories().add(cat2);
- Product p1 = Model1Factory.eINSTANCE.createProduct();
- p1.setName("P1");
- cat1.getProducts().add(p1);
- Product p2 = Model1Factory.eINSTANCE.createProduct();
- p2.setName("P2");
- cat1.getProducts().add(p2);
- Product p3 = Model1Factory.eINSTANCE.createProduct();
- p3.setName("P3");
- cat2.getProducts().add(p3);
- return cat1;
- }
+public class HibernateTest
+{
+ private static final String REPOSITORY_NAME = "repo1";
+
+ public static void main(String[] args) throws Exception
+ {
+ IManagedContainer container = initContainer();
+
+ // Start the transport and create a repository
+ JVMUtil.getAcceptor(container, "default"); // Start the JVM transport
+ CDOServerUtil.addRepository(container, createRepository()); // Start a CDO respository
+
+ // Establish a communications connection and open a session with the repository
+ IConnector connector = JVMUtil.getConnector(container, "default"); // Open a JVM connection
+ CDOSession session = CDOUtil.openSession(connector, REPOSITORY_NAME, true);// Open a CDO
+ // session
+ session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);// Not needed after
+ // first
+ // commit!!!
+
+ // Open a transaction, and create a new resource
+ CDOTransaction transaction = session.openTransaction();
+ Resource resource = transaction.createResource("/my/big/resource");
+ resource.getContents().add(getInputModel());
+ transaction.commit();
+
+ // Cleanup
+ session.close();
+ connector.disconnect();
+ }
+
+ private static IManagedContainer initContainer()
+ {
+ // Turn on tracing
+ OMPlatform.INSTANCE.setDebugging(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+
+ // Prepare the standalone infra structure (not needed when running inside Eclipse)
+ IManagedContainer container = ContainerUtil.createContainer(); // Create a wiring container
+ Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
+ JVMUtil.prepareContainer(container); // Prepare the JVM transport
+ CDOServerUtil.prepareContainer(container); // Prepare the CDO server
+ CDOUtil.prepareContainer(container, false); // Prepare the CDO client
+ return container;
+ }
+
+ private static IRepository createRepository() throws Exception
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(Props.PROP_SUPPORTING_AUDITS, "false");
+ props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "false");
+ props.put(Props.PROP_VERIFYING_REVISIONS, "false");
+ props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
+ props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
+ return CDOServerUtil.createRepository(REPOSITORY_NAME, createStore(), props);
+ }
+
+ private static IStore createStore() throws Exception
+ {
+ DriverManager.setLogWriter(new PrintWriter(System.out));
+ Driver driver = new com.mysql.jdbc.Driver();
+ DriverManager.registerDriver(driver);
+ String driverName = driver.getClass().getName();
+ String dialectName = MySQLInnoDBDialect.class.getName();
+
+ Properties props = new Properties();
+ 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.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);
+ }
+
+ private static EObject getInputModel()
+ {
+ Category cat1 = Model1Factory.eINSTANCE.createCategory();
+ cat1.setName("CAT1");
+ Category cat2 = Model1Factory.eINSTANCE.createCategory();
+ cat2.setName("CAT2");
+ cat1.getCategories().add(cat2);
+ Product p1 = Model1Factory.eINSTANCE.createProduct();
+ p1.setName("P1");
+ cat1.getProducts().add(p1);
+ Product p2 = Model1Factory.eINSTANCE.createProduct();
+ p2.setName("P2");
+ cat1.getProducts().add(p2);
+ Product p3 = Model1Factory.eINSTANCE.createProduct();
+ p3.setName("P3");
+ cat2.getProducts().add(p3);
+ return cat1;
+ }
}