diff options
author | Martin Taal | 2012-11-08 12:27:37 +0000 |
---|---|---|
committer | Martin Taal | 2012-11-08 12:27:37 +0000 |
commit | 78326471dcb1b490c85271d45efe86c3e76c8191 (patch) | |
tree | f27e3076fc4a909bcfd361eacf45925218b278ad | |
parent | 0a7004d5082934bcbb55df64c877ae5ce68b35b8 (diff) | |
download | cdo-78326471dcb1b490c85271d45efe86c3e76c8191.tar.gz cdo-78326471dcb1b490c85271d45efe86c3e76c8191.tar.xz cdo-78326471dcb1b490c85271d45efe86c3e76c8191.zip |
[244141] - [Hibernate] Store to support auditing mode
19 files changed, 345 insertions, 163 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF index 53c3583521..05c7f2c9c8 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF @@ -11,20 +11,23 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)", org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)", - org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)", - org.eclipse.emf.cdo.server.hibernate;bundle-version="[4.0.0,5.0.0)" -Import-Package: org.eclipse.emf.teneo;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.mapper;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.pannotation;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.xml;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.extension;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.hibernate.annotations;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.hibernate.mapper;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.hibernate.hbannotation;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.simpledom;version="[2.0.0,3.0.0)" -Export-Package: org.eclipse.emf.cdo.server.hibernate.internal.teneo;version="4.1.100";x-friends:="org.eclipse.emf.cdo.tests.hibernate", - org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle;version="4.1.100";x-friends:="org.eclipse.emf.cdo.tests.hibernate", - org.eclipse.emf.cdo.server.hibernate.teneo;version="4.1.100" + org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)" +Import-Package: org.eclipse.emf.cdo.security;version="[4.0.0,5.0.0)", + org.eclipse.emf.cdo.server.hibernate;version="[4.0.0,5.0.0)", + org.eclipse.emf.cdo.server.internal.hibernate;version="[4.0.0,5.0.0)", + org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;version="[4.0.0,5.0.0)", + org.eclipse.emf.teneo;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.annotations.mapper;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.annotations.pannotation;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.annotations.xml;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.extension;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.hibernate.annotations;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.hibernate.hbannotation;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.hibernate.mapper;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.simpledom;version="[2.0.1,3.0.0)" +Export-Package: org.eclipse.emf.cdo.server.hibernate.internal.teneo;version="4.2.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate", + org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle;version="4.2.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate", + org.eclipse.emf.cdo.server.hibernate.teneo;version="4.2.0" Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM$Activator diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java index 006013a38b..09b729c7e7 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java @@ -11,9 +11,9 @@ */ package org.eclipse.emf.cdo.server.hibernate.internal.teneo; -import org.eclipse.emf.cdo.common.model.CDOModelUtil; import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.cdo.etypes.EtypesPackage; +import org.eclipse.emf.cdo.security.SecurityPackage; import org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM; import org.eclipse.emf.cdo.server.hibernate.teneo.CDOMappingGenerator; import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateConstants; @@ -96,6 +96,7 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider // merge the store properties with the mapping provider properties // the mapping provider props take precedence + // this also prevents overwriting the original properties final Properties properties = new Properties(); properties.putAll(storeProperties); @@ -106,19 +107,18 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider // translate the list of EPackages to an array boolean hasXMLTypePackage = false; - final List<EPackage> epacks = getHibernateStore().getPackageHandler().getEPackages(); + final List<EPackage> epacks = getHibernateStore().getModelEPackages(); final ListIterator<EPackage> iterator = epacks.listIterator(); while (iterator.hasNext()) { final EPackage epack = iterator.next(); - if (CDOModelUtil.isSystemPackage(epack) && epack != EtypesPackage.eINSTANCE) + if (epack == XMLTypePackage.eINSTANCE) { - iterator.remove(); + hasXMLTypePackage = true; } - else if (epack == XMLTypePackage.eINSTANCE) + if (SecurityPackage.eNS_URI.equals(epack.getNsURI())) { - hasXMLTypePackage = true; - // iterator.remove(); + setEntityOnSecurityModel(epack); } } @@ -151,11 +151,30 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider // to solve an issue with older versions of teneo hbm = hbm.replaceAll("_cont", "cont"); //$NON-NLS-1$ //$NON-NLS-2$ - // System.err.println(hbm); + System.err.println(hbm); return hbm; } + private void setEntityOnSecurityModel(EPackage ePackage) + { + for (EClassifier eClassifier : ePackage.getEClassifiers()) + { + if (eClassifier instanceof EClass) + { + final EClass eClass = (EClass)eClassifier; + if (eClass.getEAnnotation(Constants.ANNOTATION_SOURCE_TENEO_JPA) != null) + { + return; + } + final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); + eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA); + eAnnotation.getDetails().put("value", "@Entity(name=\"CdoSecurity" + eClass.getName() + "\")"); + eClass.getEAnnotations().add(eAnnotation); + } + } + } + private void addTypeAnnotationToXMLTypes() { for (EClassifier eClassifier : XMLTypePackage.eINSTANCE.getEClassifiers()) @@ -185,11 +204,20 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider return; } - final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); - eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA); - final String typeAnnotation = "@Type(type=\"" + type + "\")"; - eAnnotation.getDetails().put("value", typeAnnotation); - eDataType.getEAnnotations().add(eAnnotation); + { + final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); + eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA); + final String typeAnnotation = "@Type(type=\"" + type + "\")"; + eAnnotation.getDetails().put("value", typeAnnotation); + eDataType.getEAnnotations().add(eAnnotation); + } + { + final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); + eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA_AUDITING); + final String typeAnnotation = "@Type(type=\"" + type + "\")"; + eAnnotation.getDetails().put("value", typeAnnotation); + eDataType.getEAnnotations().add(eAnnotation); + } } private void addTransientAnnotationToEClass(EClass eClass) diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF index 8b16fd65c0..c92764baaf 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.server.hibernate;singleton:=true -Bundle-Version: 4.1.100.qualifier +Bundle-Version: 4.2.0.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -41,4 +41,12 @@ Import-Package: org.apache.log4j;version="[1.2.12, 1.3.0)", org.hibernate.tuple.component;version="[4.0.0,5.0.0)", org.hibernate.tuple.entity;version="[4.0.0,5.0.0)", org.hibernate.type;version="[4.0.0,5.0.0)", - org.hibernate.usertype;version="[4.0.0,5.0.0)" + org.hibernate.usertype;version="[4.0.0,5.0.0)", + org.eclipse.emf.teneo;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.extension;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.annotations.mapper;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.hibernate;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.hibernate.mapper;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.hibernate.auditing;version="[2.0.1, 3.0.0)", + org.eclipse.emf.teneo.hibernate.auditing.model.teneoauditing;version="[2.0.1, 3.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/resource.hbm.xml b/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/resource.hbm.xml index d765f050f2..87748e0c18 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/resource.hbm.xml +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/mappings/resource.hbm.xml @@ -84,6 +84,12 @@ <tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/> <property name="contents" type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOBlobUserType"/> </subclass> + <subclass entity-name="CDOFileResource" abstract="false" lazy="false" extends="CDOResourceNode" discriminator-value="CDOFileResource"> + <meta attribute="eclassName">CDOFileResource</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/CDO/Eresource/4.0.0</meta> + <tuplizer entity-mode="pojo" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/> + <tuplizer entity-mode="dynamic-map" class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"/> + </subclass> <class name="org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreLob" table="`cdo_lob`" lazy="false"> <id name="id"/> diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java index a0ac4851e7..7344c3b244 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateStore.java @@ -29,7 +29,7 @@ import org.hibernate.cfg.Configuration; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IHibernateStore extends IStore, IDBConnectionProvider +public interface IHibernateStore extends IStore, IDBConnectionProvider, IStore.CanHandleClientAssignedIDs { /** * @since 4.0 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java index 4e1a649e34..2de7487a2f 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java @@ -69,6 +69,7 @@ public class HibernateQueryHandler implements IQueryHandler // create the query final Query query = session.createQuery(info.getQueryString()); + query.setReadOnly(true); // get the parameters with some parameter conversion int firstResult = -1; 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 82daebf604..3f21ce1373 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 @@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOID.ObjectType; import org.eclipse.emf.cdo.common.model.CDOClassifierRef; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.etypes.EtypesPackage; import org.eclipse.emf.cdo.server.ISession; import org.eclipse.emf.cdo.server.ITransaction; import org.eclipse.emf.cdo.server.IView; @@ -35,6 +37,17 @@ import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.teneo.Constants; +import org.eclipse.emf.teneo.PackageRegistryProvider; +import org.eclipse.emf.teneo.PersistenceOptions; +import org.eclipse.emf.teneo.annotations.mapper.PersistenceMappingBuilder; +import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedModel; +import org.eclipse.emf.teneo.hibernate.EMFInterceptor; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbSessionDataStore; +import org.eclipse.emf.teneo.hibernate.auditing.model.teneoauditing.TeneoauditingPackage; +import org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; @@ -51,10 +64,13 @@ import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -65,6 +81,8 @@ import java.util.Set; */ public class HibernateStore extends Store implements IHibernateStore { + public static final String PERSISTENCE_XML = PersistenceOptions.PERSISTENCE_XML; + public static final String TYPE = "hibernate"; //$NON-NLS-1$ public static final String ID_TYPE_EANNOTATION_SOURCE = "teneo.cdo"; @@ -87,9 +105,7 @@ public class HibernateStore extends Store implements IHibernateStore */ private static ThreadLocal<HibernateStore> currentHibernateStore = new ThreadLocal<HibernateStore>(); - private Configuration hibernateConfiguration; - - private SessionFactory hibernateSessionFactory; + private HbSessionDataStore cdoDataStore; private HibernatePackageHandler packageHandler; @@ -99,9 +115,7 @@ public class HibernateStore extends Store implements IHibernateStore private SystemInformation systemInformation; - private Map<String, EClass> entityNameToEClass; - - private Map<String, String> eClassToEntityName; + private List<EPackage> auditEPackages; private Map<String, String> identifierPropertyNameByEntity; @@ -119,8 +133,8 @@ public class HibernateStore extends Store implements IHibernateStore public HibernateStore(IHibernateMappingProvider mappingProvider, Properties properties) { - super(TYPE, OBJECT_ID_TYPES, set(ChangeFormat.REVISION), set(RevisionTemporality.NONE), - set(RevisionParallelism.NONE)); + super(TYPE, OBJECT_ID_TYPES, set(ChangeFormat.REVISION), + set(RevisionTemporality.NONE, RevisionTemporality.AUDITING), set(RevisionParallelism.NONE)); this.mappingProvider = mappingProvider; packageHandler = new HibernatePackageHandler(this); this.properties = properties; @@ -131,6 +145,11 @@ public class HibernateStore extends Store implements IHibernateStore } } + public boolean isAuditing() + { + return getRevisionTemporality() == RevisionTemporality.AUDITING; + } + public CDOBranchPoint getMainBranchHead() { if (mainBranchHead == null) @@ -146,21 +165,6 @@ public class HibernateStore extends Store implements IHibernateStore return identifierPropertyNameByEntity.get(entityName); } - public void addEntityNameEClassMapping(String entityName, EClass eClass) - { - if (entityNameToEClass.get(entityName) != null) - { - final EClass currentEClass = entityNameToEClass.get(entityName); - throw new IllegalArgumentException("There is a entity name collision for EClasses " //$NON-NLS-1$ - + currentEClass.getEPackage().getName() + "." + currentEClass.getName() + "/" //$NON-NLS-1$ //$NON-NLS-2$ - + eClass.getEPackage().getName() + "." + eClass.getName()); //$NON-NLS-1$ - } - - entityNameToEClass.put(entityName, eClass); - eClassToEntityName.put(eClass.getEPackage().getNsURI() + CDOClassifierRef.URI_SEPARATOR + eClass.getName(), - entityName); - } - public Properties getProperties() { if (properties == null || properties.isEmpty()) @@ -177,15 +181,48 @@ public class HibernateStore extends Store implements IHibernateStore return properties; } + public void addEntityNameEClassMapping(String entityName, EClass eClass) + { + cdoDataStore.addEntityNameEClassMapping(entityName, eClass); + } + + /** + * Returns all model epackages, so no audit epackages or system + * epackages. + */ + public List<EPackage> getModelEPackages() + { + final List<EPackage> epacks = getPackageHandler().getEPackages(); + final ListIterator<EPackage> iterator = epacks.listIterator(); + while (iterator.hasNext()) + { + final EPackage epack = iterator.next(); + if (CDOModelUtil.isSystemPackage(epack) && epack != EtypesPackage.eINSTANCE) + { + iterator.remove(); + } + else if (isAuditEPackage(epack)) + { + // an auditing package + iterator.remove(); + } + } + return epacks; + } + + private boolean isAuditEPackage(EPackage ePackage) + { + return TeneoauditingPackage.eNS_URI.equals(ePackage.getNsURI()) + || ePackage.getEAnnotation(Constants.ANNOTATION_SOURCE_AUDITING) != null; + } + public String getEntityName(EClass eClass) { if (eClass == null) { throw new IllegalArgumentException("EClass argument is null"); //$NON-NLS-1$ } - - final String entityName = eClassToEntityName.get(eClass.getEPackage().getNsURI() + CDOClassifierRef.URI_SEPARATOR - + eClass.getName()); + final String entityName = cdoDataStore.toEntityName(eClass); if (entityName == null) { throw new IllegalArgumentException("EClass " + eClass.getName() //$NON-NLS-1$ @@ -202,8 +239,9 @@ public class HibernateStore extends Store implements IHibernateStore throw new IllegalArgumentException("classifierRef argument is null"); //$NON-NLS-1$ } - final String entityName = eClassToEntityName.get(classifierRef.getPackageURI() + CDOClassifierRef.URI_SEPARATOR - + classifierRef.getClassifierName()); + EClass eClass = (EClass)classifierRef.resolve(getRepository().getPackageRegistry()); + + final String entityName = cdoDataStore.toEntityName(eClass); if (entityName == null) { throw new IllegalArgumentException("EClass " + classifierRef //$NON-NLS-1$ @@ -220,7 +258,7 @@ public class HibernateStore extends Store implements IHibernateStore throw new IllegalArgumentException("entityname argument is null"); //$NON-NLS-1$ } - final EClass eClass = entityNameToEClass.get(entityName); + final EClass eClass = cdoDataStore.toEClass(entityName); if (eClass == null) { throw new IllegalArgumentException("entityname " + entityName //$NON-NLS-1$ @@ -232,13 +270,12 @@ public class HibernateStore extends Store implements IHibernateStore public Configuration getHibernateConfiguration() { - return hibernateConfiguration; + return cdoDataStore.getConfiguration(); } - @SuppressWarnings("deprecation") public synchronized SessionFactory getHibernateSessionFactory() { - if (hibernateSessionFactory == null) + if (cdoDataStore == null) { if (TRACER.isEnabled()) { @@ -247,22 +284,20 @@ public class HibernateStore extends Store implements IHibernateStore currentHibernateStore.set(this); - entityNameToEClass = new HashMap<String, EClass>(); - eClassToEntityName = new HashMap<String, String>(); identifierPropertyNameByEntity = new HashMap<String, String>(); try { - initConfiguration(); + initDataStore(); // this has to be done before the classmapping is iterated // otherwise it is not initialized - hibernateSessionFactory = hibernateConfiguration.buildSessionFactory(); + SessionFactory hibernateSessionFactory = cdoDataStore.getSessionFactory(); ServiceRegistry serviceRegistry = ((SessionFactoryImpl)hibernateSessionFactory).getServiceRegistry(); final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class); eventListenerRegistry.setListeners(EventType.MERGE, new CDOMergeEventListener()); - final Iterator<?> iterator = hibernateConfiguration.getClassMappings(); + final Iterator<?> iterator = cdoDataStore.getConfiguration().getClassMappings(); while (iterator.hasNext()) { final PersistentClass pc = (PersistentClass)iterator.next(); @@ -275,13 +310,22 @@ public class HibernateStore extends Store implements IHibernateStore identifierPropertyNameByEntity.put(pc.getEntityName(), pc.getIdentifierProperty().getName()); } } + catch (Throwable t) + { + t.printStackTrace(System.err); + if (TRACER.isEnabled()) + { + TRACER.trace(t); + } + throw new RuntimeException(t); + } finally { currentHibernateStore.set(null); } } - return hibernateSessionFactory; + return cdoDataStore.getSessionFactory(); } public Connection getConnection() @@ -438,26 +482,25 @@ public class HibernateStore extends Store implements IHibernateStore @Override protected void doDeactivate() throws Exception { - if (hibernateSessionFactory != null) + Configuration configuration = null; + if (cdoDataStore != null) { + configuration = cdoDataStore.getConfiguration(); if (TRACER.isEnabled()) { TRACER.trace("Closing SessionFactory"); //$NON-NLS-1$ } - - hibernateSessionFactory.close(); - hibernateSessionFactory = null; + cdoDataStore.close(); } // and now do the drop action - if (doDropSchema) + if (configuration != null && doDropSchema) { - final Configuration conf = getHibernateConfiguration(); - final SchemaExport se = new SchemaExport(conf); + final SchemaExport se = new SchemaExport(configuration); se.drop(false, true); } - hibernateConfiguration = null; + cdoDataStore = null; LifecycleUtil.deactivate(packageHandler, OMLogger.Level.WARN); super.doDeactivate(); } @@ -487,23 +530,23 @@ public class HibernateStore extends Store implements IHibernateStore TRACER.trace("Re-Initializing HibernateStore"); //$NON-NLS-1$ } - if (hibernateSessionFactory != null) + if (cdoDataStore != null) { - if (!hibernateSessionFactory.isClosed()) + if (!cdoDataStore.isClosed()) { if (TRACER.isEnabled()) { TRACER.trace("Closing SessionFactory"); //$NON-NLS-1$ } - hibernateSessionFactory.close(); + cdoDataStore.close(); } - hibernateSessionFactory = null; + cdoDataStore = null; } } - protected void initConfiguration() + protected void initDataStore() { if (TRACER.isEnabled()) { @@ -514,11 +557,31 @@ public class HibernateStore extends Store implements IHibernateStore try { - hibernateConfiguration = new Configuration(); + PackageRegistryProvider.getInstance().setThreadPackageRegistry(getRepository().getPackageRegistry()); + + cdoDataStore = new CDODataStore(); + cdoDataStore.setResetConfigurationOnInitialization(false); + cdoDataStore.setName("cdo"); + cdoDataStore.setPackageRegistry(getRepository().getPackageRegistry()); + cdoDataStore.getExtensionManager().registerExtension(EMFInterceptor.class.getName(), + CDOInterceptor.class.getName()); + + // don't do any persistence xml mapping in this datastore + // make a local copy as it is adapted in the next if-statement + // and we want to keep the original one untouched, if not + // subsequent test runs will fail as they use the same + // properties object + final Properties props = new Properties(); + props.putAll(getProperties()); + props.remove(PersistenceOptions.PERSISTENCE_XML); + cdoDataStore.setDataStoreProperties(props); + Configuration hibernateConfiguration = cdoDataStore.getConfiguration(); + if (mappingProvider != null) { mappingProvider.setHibernateStore(this); mappingXml = mappingProvider.getMapping(); + System.err.println(mappingXml); hibernateConfiguration.addXML(mappingXml); } @@ -529,14 +592,8 @@ public class HibernateStore extends Store implements IHibernateStore in = OM.BUNDLE.getInputStream(RESOURCE_HBM_PATH); hibernateConfiguration.addInputStream(in); - hibernateConfiguration.setInterceptor(new CDOInterceptor()); + // hibernateConfiguration.setInterceptor(new CDOInterceptor()); - // make a local copy as it is adapted in the next if-statement - // and we want to keep the original one untouched, if not - // subsequent test runs will fail as they use the same - // properties object - final Properties props = new Properties(); - props.putAll(getProperties()); hibernateConfiguration.setProperties(props); // prevent the drop on close because the sessionfactory is also closed when @@ -547,11 +604,39 @@ public class HibernateStore extends Store implements IHibernateStore doDropSchema = true; // note that the value create also re-creates the db and drops the old one hibernateConfiguration.setProperty(Environment.HBM2DDL_AUTO, HBM2DLL_UPDATE); + cdoDataStore.getDataStoreProperties().setProperty(Environment.HBM2DDL_AUTO, HBM2DLL_UPDATE); } else { doDropSchema = false; } + + final List<EPackage> ePackages = new ArrayList<EPackage>(packageHandler.getEPackages()); + + // get rid of the system packages + for (EPackage ePackage : packageHandler.getEPackages()) + { + if (CDOModelUtil.isSystemPackage(ePackage) && ePackage != EtypesPackage.eINSTANCE) + { + ePackages.remove(ePackage); + } + } + // remove the persistence xml if no epackages as this won't work without + // epackages + if (ePackages.size() == 0 && props.getProperty(PersistenceOptions.PERSISTENCE_XML) != null) + { + cdoDataStore.getDataStoreProperties().remove(PersistenceOptions.PERSISTENCE_XML); + } + + if (isAuditing()) + { + auditEPackages = createAuditEPackages(cdoDataStore); + final String auditMapping = mapAuditingEPackages(cdoDataStore, auditEPackages); + System.err.println(auditMapping); + hibernateConfiguration.addXML(auditMapping); + cdoDataStore.setAuditing(true); + } + cdoDataStore.setEPackages(ePackages.toArray(new EPackage[0])); } catch (Exception ex) { @@ -559,6 +644,7 @@ public class HibernateStore extends Store implements IHibernateStore } finally { + PackageRegistryProvider.getInstance().setThreadPackageRegistry(null); IOUtil.close(in); } } @@ -587,4 +673,73 @@ public class HibernateStore extends Store implements IHibernateStore { return mappingXml; } + + private List<EPackage> createAuditEPackages(HbDataStore dataStore) + { + final PersistenceOptions po = dataStore.getPersistenceOptions(); + + final List<EPackage> epacks = new ArrayList<EPackage>(); + for (EPackage ePackage : getModelEPackages()) + { + if (!CDOModelUtil.isSystemPackage(ePackage) && !isAuditEPackage(ePackage)) + { + epacks.add(dataStore.getAuditHandler().createAuditingEPackage(dataStore, ePackage, + getRepository().getPackageRegistry(), po)); + } + } + epacks.add(TeneoauditingPackage.eINSTANCE); + getRepository().getPackageRegistry().put(TeneoauditingPackage.eNS_URI, TeneoauditingPackage.eINSTANCE); + return epacks; + } + + public String mapAuditingEPackages(HbDataStore dataStore, List<EPackage> auditEPackages) + { + // create a new persistence options to not change the original + final PersistenceOptions po = dataStore.getExtensionManager().getExtension(PersistenceOptions.class); + final Properties props = new Properties(dataStore.getPersistenceOptions().getProperties()); + props.remove(PersistenceOptions.PERSISTENCE_XML); + if (props.containsKey(PersistenceOptions.AUDITING_PERSISTENCE_XML)) + { + props.setProperty(PersistenceOptions.PERSISTENCE_XML, PersistenceOptions.AUDITING_PERSISTENCE_XML); + } + + PAnnotatedModel paModel = dataStore.getExtensionManager().getExtension(PersistenceMappingBuilder.class) + .buildMapping(auditEPackages, po, dataStore.getExtensionManager(), dataStore.getPackageRegistry()); + final HibernateMappingGenerator hmg = dataStore.getExtensionManager().getExtension(HibernateMappingGenerator.class); + hmg.setPersistenceOptions(po); + final String hbm = hmg.generateToString(paModel); + return hbm; + } + + private class CDODataStore extends HbSessionDataStore + { + + private static final long serialVersionUID = 1L; + + @Override + protected void addContainerMapping(PersistentClass pc) + { + // prevent container mapping for cdo objects + if (pc.getTuplizerMap() != null) + { + for (Object tuplizerName : pc.getTuplizerMap().values()) + { + if (((String)tuplizerName).contains("org.eclipse.emf.cdo")) + { + return; + } + } + } + super.addContainerMapping(pc); + } + + @Override + protected void mapModel() + { + if (getPersistenceOptions().getMappingFilePath() != null || getPersistenceOptions().isUseMappingFile()) + { + super.mapModel(); + } + } + } } 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 4334665280..6074fa9186 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 @@ -164,13 +164,6 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS } } - /** Clears the current hibernate session and sets a new one in the thread context */ - public void resetHibernateSession() - { - endHibernateSession(); - beginHibernateSession(); - } - /** * @return the backing store */ @@ -195,6 +188,8 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS assert hibernateSession == null; final SessionFactory sessionFactory = getStore().getHibernateSessionFactory(); hibernateSession = sessionFactory.openSession(); + hibernateSession.setDefaultReadOnly(true); + hibernateSession.setFlushMode(FlushMode.MANUAL); hibernateSession.beginTransaction(); } @@ -261,7 +256,9 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS } /** - * @return the current hibernate session. If there is none then a new one is created and a transaction is started + * @return the current hibernate session. If there is none then a new one is created and a transaction is started. + * + * Note the default is a readonly flushmode manual session. */ public Session getHibernateSession() { @@ -269,7 +266,6 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS { beginHibernateSession(); } - return hibernateSession; } @@ -278,7 +274,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS * * @return a newly created Hibernate Session */ - public Session getNewHibernateSession() + public Session getNewHibernateSession(boolean readOnly) { if (hibernateSession != null) { @@ -660,8 +656,8 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS try { // start with fresh hibernate session to prevent side effects - final Session session = getNewHibernateSession(); - session.setFlushMode(FlushMode.MANUAL); + final Session session = getNewHibernateSession(false); + session.setDefaultReadOnly(false); // order is 1) insert, 2) update and then delete // this order is the most stable! Do not change it without testing diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java index c71ea6f3b5..997ce839d5 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOInterceptor.java @@ -15,7 +15,8 @@ import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.server.internal.hibernate.HibernateUtil; -import org.hibernate.EmptyInterceptor; +import org.eclipse.emf.teneo.hibernate.EMFInterceptor; + import org.hibernate.type.Type; import java.io.Serializable; @@ -25,7 +26,7 @@ import java.io.Serializable; * * @author Martin Taal */ -public class CDOInterceptor extends EmptyInterceptor +public class CDOInterceptor extends EMFInterceptor { private static final long serialVersionUID = 1L; @@ -56,7 +57,7 @@ public class CDOInterceptor extends EmptyInterceptor { if (!(object instanceof CDORevision)) { - return object.getClass().getName(); + return super.getEntityName(object); } return HibernateUtil.getInstance().getEntityName(object); 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 6acfb42e79..a661d7945c 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 @@ -167,7 +167,8 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer public EntityNameResolver[] getEntityNameResolvers() { - return new EntityNameResolver[] { new CDOEntityNameResolver() }; + return new EntityNameResolver[0]; + // return new EntityNameResolver[] { new CDOEntityNameResolver() }; } private class CDOEntityNameResolver implements EntityNameResolver 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 b28293508e..48aafaf7ea 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 @@ -182,7 +182,6 @@ org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=2 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF index 192fb68177..fd624beb3c 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/META-INF/MANIFEST.MF @@ -14,17 +14,18 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.net4j.tcp;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)", - org.eclipse.emf.cdo.server.hibernate;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.server.db;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.tests;bundle-version="[4.0.0,5.0.0)", - org.eclipse.emf.cdo.server.hibernate.teneo;bundle-version="[4.0.0,5.0.0)", org.hsqldb;bundle-version="[2.0.0,3.0.0)", com.mysql.jdbc;bundle-version="[5.1.7,6.0.0)", org.dom4j;bundle-version="[1.6.1,2.0.0)", javax.persistence;bundle-version="[2.0.0,3.0.0)" Export-Package: mappings;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.hudson", org.eclipse.emf.cdo.tests.hibernate;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.hudson" -Import-Package: org.eclipse.emf.teneo;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.pamodel.impl;version="[2.0.0,3.0.0)", - org.eclipse.emf.teneo.annotations.pamodel.util;version="[2.0.0,3.0.0)" +Import-Package: org.eclipse.emf.teneo;version="[2.0.1,3.0.0)", + org.eclipse.emf.cdo.server.hibernate;version="[4.0.0,5.0.0)", + org.eclipse.emf.cdo.server.hibernate.teneo;version="[4.0.0,5.0.0)", + org.eclipse.emf.cdo.server.internal.hibernate;version="[4.0.0,5.0.0)", + org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.annotations.pamodel.impl;version="[2.0.1,3.0.0)", + org.eclipse.emf.teneo.annotations.pamodel.util;version="[2.0.1,3.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties index 27dd2993c4..ac2e5672fa 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties @@ -28,3 +28,4 @@ hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider #hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect teneo.mapping.cascade_policy_on_non_containment=PERSIST,MERGE +teneo.mapping.persistence_xml.parse.lenient=true
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java index 3b21c0dde1..3edb136be4 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java @@ -10,13 +10,13 @@ */ package org.eclipse.emf.cdo.tests.hibernate; +import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore; import org.eclipse.emf.cdo.tests.AllConfigs; import org.eclipse.emf.cdo.tests.AttributeTest; -import org.eclipse.emf.cdo.tests.AuditSameSessionTest; -import org.eclipse.emf.cdo.tests.AuditTest; import org.eclipse.emf.cdo.tests.BackupTest; import org.eclipse.emf.cdo.tests.CommitInfoTest; import org.eclipse.emf.cdo.tests.DynamicXSDTest; +import org.eclipse.emf.cdo.tests.EMFCompareTest; import org.eclipse.emf.cdo.tests.ExternalReferenceTest; import org.eclipse.emf.cdo.tests.LockingManagerRestartRepositoryTest; import org.eclipse.emf.cdo.tests.LockingManagerRestartSessionTest; @@ -26,8 +26,8 @@ import org.eclipse.emf.cdo.tests.LockingNotificationsTest; import org.eclipse.emf.cdo.tests.MEMStoreQueryTest; import org.eclipse.emf.cdo.tests.MultiValuedOfAttributeTest; import org.eclipse.emf.cdo.tests.UnsetTest; +import org.eclipse.emf.cdo.tests.WorkspaceTest; import org.eclipse.emf.cdo.tests.XATransactionTest; -import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_258933_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_272861_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_279982_Test; @@ -44,8 +44,6 @@ import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import org.eclipse.emf.cdo.util.CommitException; -import org.eclipse.emf.teneo.PersistenceOptions; - import java.util.List; import junit.framework.Test; @@ -73,7 +71,14 @@ public class AllTestsHibernate extends AllConfigs protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) { // testClasses.clear(); - // testClasses.add(Hibernate_BackupTest.class); + + // removed stalls + // testClasses.remove(AuditSameSessionTest.class); + // testClasses.add(AuditTest.class); + // testClasses.add(AuditSameSessionTest.class); + // testClasses.add(StickyViewsTest.class); + + // testClasses.add(HibernateQueryTest.class); // if (true) // { // return; @@ -96,6 +101,9 @@ public class AllTestsHibernate extends AllConfigs super.initTestClasses(testClasses, scenario); + // workspaces are not supported + testClasses.remove(WorkspaceTest.class); + testClasses.remove(DynamicXSDTest.class); // delete repo is not yet supported @@ -140,15 +148,14 @@ public class AllTestsHibernate extends AllConfigs // Locking manager not supported testClasses.remove(LockingManagerTest.class); - // results in infinite loops it seems - // runs okay when run standalone - // testClasses.remove(Bugzilla_273565_Test.class); - // audit support to do // bug 244141 - testClasses.remove(AuditTest.class); - testClasses.remove(AuditSameSessionTest.class); - testClasses.remove(Bugzilla_252214_Test.class); + // testClasses.remove(AuditTest.class); + // testClasses.remove(AuditSameSessionTest.class); + // testClasses.remove(Bugzilla_252214_Test.class); + + // problem with wrong version of EMF Compare + testClasses.remove(EMFCompareTest.class); // replace a test with our local implementation: // the MultiValueOfAttributeTest class has a method @@ -236,7 +243,7 @@ public class AllTestsHibernate extends AllConfigs final IRepositoryConfig repConfig = getRepositoryConfig(); final HibernateConfig hbConfig = (HibernateConfig)repConfig; final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml"; - hbConfig.getAdditionalProperties().put(PersistenceOptions.PERSISTENCE_XML, persistenceXML); + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); super.doSetUp(); } @@ -249,27 +256,5 @@ public class AllTestsHibernate extends AllConfigs hbConfig.getAdditionalProperties().clear(); super.doTearDown(); } - - // - // @Override - // public void testExportFeatureMap() throws Exception - // { - // } - // - // @Override - // public void testExportExternalReference() throws Exception - // { - // } - // - // @Override - // public void testImportFeatureMap() throws Exception - // { - // } - // - // @Override - // public void testImportExternalReference() throws Exception - // { - // } - } } diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_362270_Test.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_362270_Test.java index ae8b5a25c8..4e387d8092 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_362270_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_362270_Test.java @@ -10,11 +10,10 @@ */ package org.eclipse.emf.cdo.tests.hibernate; +import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore; import org.eclipse.emf.cdo.tests.ExternalReferenceTest; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; -import org.eclipse.emf.teneo.PersistenceOptions; - /** * Read external reference annotation. * @@ -48,7 +47,7 @@ public class HibernateBugzilla_362270_Test extends ExternalReferenceTest final IRepositoryConfig repConfig = getRepositoryConfig(); final HibernateConfig hbConfig = (HibernateConfig)repConfig; final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml"; - hbConfig.getAdditionalProperties().put(PersistenceOptions.PERSISTENCE_XML, persistenceXML); + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); super.doSetUp(); } diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java index 67fcdb6264..1d1db4a400 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java @@ -28,7 +28,7 @@ import java.util.Properties; */ public class HibernateConfig extends RepositoryConfig { - public static final String STAORE_NAME = "Hibernate"; + public static final String STORE_NAME = "Hibernate"; public static final HibernateConfig INSTANCE = new HibernateConfig(); @@ -40,13 +40,13 @@ public class HibernateConfig extends RepositoryConfig public HibernateConfig() { - super(STAORE_NAME, false, false, IDGenerationLocation.STORE); + super(STORE_NAME, true, false, IDGenerationLocation.STORE); } @Override protected String getStoreName() { - return STAORE_NAME; + return STORE_NAME; } @Override diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalAnnotationTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalAnnotationTest.java index b3fcb4ba05..7d13289351 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalAnnotationTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalAnnotationTest.java @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.tests.hibernate; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.tests.AbstractCDOTest; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; @@ -29,7 +30,6 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; -import org.eclipse.emf.teneo.PersistenceOptions; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -49,7 +49,7 @@ public class HibernateExternalAnnotationTest extends AbstractCDOTest final IRepositoryConfig repConfig = getRepositoryConfig(); final HibernateConfig hbConfig = (HibernateConfig)repConfig; final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml"; - hbConfig.getAdditionalProperties().put(PersistenceOptions.PERSISTENCE_XML, persistenceXML); + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); super.doSetUp(); } diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalReferenceTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalReferenceTest.java index 6eba9f3a01..2e4bf5f960 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalReferenceTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalReferenceTest.java @@ -10,11 +10,10 @@ */ package org.eclipse.emf.cdo.tests.hibernate; +import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore; import org.eclipse.emf.cdo.tests.ExternalReferenceTest; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; -import org.eclipse.emf.teneo.PersistenceOptions; - /** * Test {@link ExternalReferenceTest}, disables some testcases which will never work anyway. * @@ -65,7 +64,7 @@ public class HibernateExternalReferenceTest extends ExternalReferenceTest final IRepositoryConfig repConfig = getRepositoryConfig(); final HibernateConfig hbConfig = (HibernateConfig)repConfig; final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml"; - hbConfig.getAdditionalProperties().put(PersistenceOptions.PERSISTENCE_XML, persistenceXML); + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); super.doSetUp(); } diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateXATransactionTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateXATransactionTest.java index 6ae75d1b7b..bdd7d0b2bb 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateXATransactionTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateXATransactionTest.java @@ -10,11 +10,10 @@ */ package org.eclipse.emf.cdo.tests.hibernate; +import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore; import org.eclipse.emf.cdo.tests.XATransactionTest; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; -import org.eclipse.emf.teneo.PersistenceOptions; - /** * Override {@link XATransactionTest} to do mapping of external references. * @@ -28,7 +27,7 @@ public class HibernateXATransactionTest extends XATransactionTest final IRepositoryConfig repConfig = getRepositoryConfig(); final HibernateConfig hbConfig = (HibernateConfig)repConfig; final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml"; - hbConfig.getAdditionalProperties().put(PersistenceOptions.PERSISTENCE_XML, persistenceXML); + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); super.doSetUp(); } |