diff options
author | Martin Taal | 2009-11-05 12:21:57 +0000 |
---|---|---|
committer | Martin Taal | 2009-11-05 12:21:57 +0000 |
commit | e7436e4fc369522df8c326e31fd8c42b153754d0 (patch) | |
tree | 68c0dc926dce4e861812f7dd06c46da07d946128 /plugins/org.eclipse.emf.cdo.server.hibernate | |
parent | 31ac39ca8d4dc1f548f881e92d50d042c69c1e4c (diff) | |
download | cdo-e7436e4fc369522df8c326e31fd8c42b153754d0.tar.gz cdo-e7436e4fc369522df8c326e31fd8c42b153754d0.tar.xz cdo-e7436e4fc369522df8c326e31fd8c42b153754d0.zip |
[294256] [Hibernate] Various changes (FeatureMap, external annotation, ...)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate')
43 files changed, 656 insertions, 104 deletions
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 7200184ccc..eb8deb2406 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 @@ -17,16 +17,17 @@ Export-Package: org.eclipse.emf.cdo.server.hibernate;version="3.0.0", org.eclipse.emf.cdo.server.internal.hibernate.bundle;version="3.0.0";x-internal:=true, org.eclipse.emf.cdo.server.internal.hibernate.info;version="3.0.0";x-friends:="org.eclipse.emf.cdo.server.hibernate.teneo,org.eclipse.emf.cdo.tests.hibernate", org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;version="3.0.0";x-friends:="org.eclipse.emf.cdo.server.hibernate.teneo,org.eclipse.emf.cdo.tests.hibernate" -Import-Package: org.hibernate;version="[3.2.0,4.0.0)", - org.hibernate.cfg;version="[3.2.0,4.0.0)", - org.hibernate.collection;version="[3.2.0,4.0.0)", - org.hibernate.criterion;version="[3.2.0,4.0.0)", - org.hibernate.engine;version="[3.2.0,4.0.0)", - org.hibernate.mapping;version="[3.2.0,4.0.0)", - org.hibernate.property;version="[3.2.0,4.0.0)", - org.hibernate.proxy;version="[3.2.0,4.0.0)", - org.hibernate.tool.hbm2ddl;version="[3.2.0,4.0.0)", - org.hibernate.tuple;version="[3.2.0,4.0.0)", - org.hibernate.tuple.entity;version="[3.2.0,4.0.0)", - org.hibernate.type;version="[3.2.0,4.0.0)", - org.hibernate.usertype;version="[3.2.0,4.0.0)" +Import-Package: org.hibernate;version="[3.3.2,4.0.0)", + org.hibernate.cfg;version="[3.3.2,4.0.0)", + org.hibernate.collection;version="[3.3.2,4.0.0)", + org.hibernate.criterion;version="[3.3.2,4.0.0)", + org.hibernate.engine;version="[3.3.2,4.0.0)", + org.hibernate.mapping;version="[3.3.2,4.0.0)", + org.hibernate.property;version="[3.3.2,4.0.0)", + org.hibernate.proxy;version="[3.3.2,4.0.0)", + org.hibernate.tool.hbm2ddl;version="[3.3.2,4.0.0)", + org.hibernate.tuple;version="[3.3.2,4.0.0)", + org.hibernate.tuple.component;version="[3.3.2,4.0.0)", + org.hibernate.tuple.entity;version="[3.3.2,4.0.0)", + org.hibernate.type;version="[3.3.2,4.0.0)", + org.hibernate.usertype;version="[3.3.2,4.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java index 853b649380..1a01170f25 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/IHibernateMappingProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 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 5302472f7d..651e532b55 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 @@ -25,4 +25,16 @@ public class CDOHibernateConstants public static final String CONTAINER_PROPERTY = "containerID"; public static final String CONTAINER_PROPERTY_COLUMN = "container_id"; + + public static final String FEATUREMAP_PROPERTY_FEATURE = "fme_feature"; + + public static final String FEATUREMAP_PROPERTY_CDATA = "fme_mixed_cdata"; + + public static final String FEATUREMAP_PROPERTY_COMMENT = "fme_mixed_comment"; + + public static final String FEATUREMAP_PROPERTY_TEXT = "fme_mixed_text"; + + public static final String FEATUREMAP_PROPERTY_ANY_PRIMITIVE = "fme_any_data"; + + public static final String FEATUREMAP_PROPERTY_ANY_REFERENCE = "fme_any_reference"; } diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/ContainerInfoConverter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/ContainerInfoConverter.java index 9fa6c490b9..3296806ca3 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/ContainerInfoConverter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/ContainerInfoConverter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCDOPackageUnitDTO.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCDOPackageUnitDTO.java index d76904ac52..1f552c8ced 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCDOPackageUnitDTO.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCDOPackageUnitDTO.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java index fce59a8a35..a3c09a00bb 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java index d2d088d52d..c7d98cad3d 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java @@ -58,6 +58,64 @@ public class HibernatePackageHandler extends Lifecycle private static final String CDO_PACKAGE_UNIT_ENTITY_NAME = "CDOPackageUnit"; + // made static and synchronized because apparently there can be multiple package handlers + // in some test cases: TestExternalReferenceTest.testOneXMIResourceManyViewsOnOneResourceSet + private static synchronized boolean writePackageUnits(InternalCDOPackageUnit[] packageUnits, + SessionFactory sessionFactory, EPackage.Registry registry) + { + if (TRACER.isEnabled()) + { + TRACER.trace("Persisting new EPackages"); + } + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + boolean err = true; + boolean updated = false; + + try + { + // first store and update the packageunits and the epackages + for (InternalCDOPackageUnit packageUnit : packageUnits) + { + final HibernateCDOPackageUnitDTO hbPackageUnitDTO = new HibernateCDOPackageUnitDTO(packageUnit); + + if (packageUnit.getPackageInfos().length > 0) + { + final String rootNSUri = packageUnit.getTopLevelPackageInfo().getPackageURI(); + final EPackage rootEPackage = registry.getEPackage(rootNSUri); + hbPackageUnitDTO.setEPackageBlob(EMFUtil.getEPackageBytes(rootEPackage, true, registry)); + } + + if (session.get("CDOPackageUnit", hbPackageUnitDTO.getNsUri()) == null) + { + session.saveOrUpdate("CDOPackageUnit", hbPackageUnitDTO); + } + + updated = true; + } + + tx.commit(); + err = false; + } + catch (Exception e) + { + e.printStackTrace(System.err); + throw new Error(e); + } + finally + { + if (err) + { + tx.rollback(); + } + + session.close(); + } + + return updated; + } + private Configuration configuration; private SessionFactory sessionFactory; @@ -120,54 +178,7 @@ public class HibernatePackageHandler extends Lifecycle public void writePackageUnits(InternalCDOPackageUnit[] packageUnits) { - if (TRACER.isEnabled()) - { - TRACER.trace("Persisting new EPackages"); - } - - Session session = getSessionFactory().openSession(); - Transaction tx = session.beginTransaction(); - boolean err = true; - boolean updated = false; - - try - { - // first store and update the packageunits and the epackages - for (InternalCDOPackageUnit packageUnit : packageUnits) - { - final HibernateCDOPackageUnitDTO hbPackageUnitDTO = new HibernateCDOPackageUnitDTO(packageUnit); - - if (packageUnit.getPackageInfos().length > 0) - { - final String rootNSUri = packageUnit.getTopLevelPackageInfo().getPackageURI(); - final EPackage.Registry registry = hibernateStore.getRepository().getPackageRegistry(); - final EPackage rootEPackage = registry.getEPackage(rootNSUri); - hbPackageUnitDTO.setEPackageBlob(EMFUtil.getEPackageBytes(rootEPackage, true, registry)); - } - - session.saveOrUpdate("CDOPackageUnit", hbPackageUnitDTO); - - updated = true; - } - - tx.commit(); - err = false; - } - catch (Exception e) - { - e.printStackTrace(System.err); - throw new Error(e); - } - finally - { - if (err) - { - tx.rollback(); - } - - session.close(); - } - + final boolean updated = writePackageUnits(packageUnits, getSessionFactory(), getPackageRegistry()); if (updated) { reset(); 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 95d8059922..9d27c304fc 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 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 0604cf8986..79da35a871 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 @@ -458,6 +458,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS public void write(IStoreAccessor.CommitContext context, OMMonitor monitor) { HibernateThreadContext.setCommitContext(context); + HibernateThreadContext.setCurrentStoreAccessor(this); if (context.getNewPackageUnits().length > 0) { writePackageUnits(context.getNewPackageUnits(), monitor); diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java index 5e9f099c7e..d4a3e80221 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateThreadContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 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 c9ba21f4ea..a3e76b57d2 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/SystemInformation.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/SystemInformation.java index 62d6c9991b..84ba23120c 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/SystemInformation.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/SystemInformation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerGetter.java index 04f9c30eeb..3ed1371ae1 100755 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerGetter.java @@ -1,6 +1,5 @@ /** - - * Copyright (c) 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerSetter.java index 222dce4cdf..bd207af7da 100755 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerSetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOContainerSetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDAnyUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDAnyUserType.java index aa25b7c435..638f3209a9 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDAnyUserType.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDAnyUserType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java index 0998278353..7b7c8c961b 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDExternalUserType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java index 32abf5504c..cd206c72bb 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDMetaRangeUserType.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java index e3f6d0137b..8d18c73c56 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertyGetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java index 96030ef87f..aeb491bd74 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOIDPropertySetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 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 1965f4f705..3ddeeb9ef3 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeGetter.java index b080809487..993d672226 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeGetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeSetter.java index 7db9e84716..f9622db80a 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeSetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyAttributeSetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java index 73b8a36133..d2dc23bfa6 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceGetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java index cba8d5d5e2..b9a1cef427 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOManyReferenceSetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 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 109f3f1a8a..71ad9a0757 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 @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java index 6cc1e057d0..9f5d046b55 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertyHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java index 33032a91cc..1a716e968e 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java index 74c1b6d6a2..60890b6c5c 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceGetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java index aa88836faf..a883c955c3 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOReferenceSetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDGetter.java index 1fa351f7e4..ad0c84892b 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDGetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDSetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDSetter.java index a088d8648b..d48db953e0 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDSetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOResourceIDSetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 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 5163146784..d663a29b5d 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 @@ -27,7 +27,9 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.hibernate.EntityMode; +import org.hibernate.EntityNameResolver; import org.hibernate.HibernateException; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.property.Getter; @@ -127,6 +129,49 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer } } + /* + * (non-Javadoc) + * @see org.hibernate.tuple.entity.EntityTuplizer#determineConcreteSubclassEntityName(java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) + */ + public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) + { + final Class<?> concreteEntityClass = entityInstance.getClass(); + if (concreteEntityClass == getMappedClass()) + { + return getEntityName(); + } + else + { + String entityName = getEntityMetamodel().findEntityNameByEntityClass(concreteEntityClass); + if (entityName == null) + { + throw new HibernateException("Unable to resolve entity name from Class [" + concreteEntityClass.getName() + "]" + + " expected instance/subclass of [" + getEntityName() + "]"); + } + + return entityName; + } + } + + public EntityMode getEntityMode() + { + return EntityMode.MAP; + } + + public EntityNameResolver[] getEntityNameResolvers() + { + return new EntityNameResolver[] { new CDOEntityNameResolver() }; + } + + private class CDOEntityNameResolver implements EntityNameResolver + { + public String resolveEntityName(Object object) + { + return getEntityName(); + } + } + // MT: probably not required as the property getter/setter do all the work // /* // * (non-Javadoc) @@ -184,12 +229,6 @@ public class CDORevisionTuplizer extends AbstractEntityTuplizer // + " not supported by this tuplizer"); // } - @Override - public EntityMode getEntityMode() - { - return EntityMode.MAP; - } - public EClass getEClass() { return eClass; diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java index ffd07490d6..153165ea72 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOTypeUserType.java @@ -1,10 +1,10 @@ /** - * Copyright (c) 2008 - 2008 Martin Taal and others + * Copyright (c) 2004 - 2009 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 - initial api * Eike Stepper - maintenance diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java index 0d40e1f2fa..bf3bc6196c 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertyGetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java index a87414d5f1..6273f2e223 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOVersionPropertySetter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 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 new file mode 100644 index 0000000000..31483d908e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryFeatureURIPropertyHandler.java @@ -0,0 +1,144 @@ +/**
+ * Copyright (c) 2004 - 2009 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 - initial api
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.cdo.server.internal.hibernate.HibernateCommitContext;
+import org.eclipse.emf.cdo.server.internal.hibernate.HibernateThreadContext;
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import org.hibernate.HibernateException;
+import org.hibernate.PropertyNotFoundException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.property.Getter;
+import org.hibernate.property.PropertyAccessor;
+import org.hibernate.property.Setter;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * Handles the string representation of the feature of the feature map entry in the database.
+ *
+ * @see CDOFeatureMapEntry#setEStructuralFeature(EStructuralFeature)
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ */
+public class FeatureMapEntryFeatureURIPropertyHandler implements PropertyAccessor, Getter, Setter
+{
+ private static final String EFEATURE_SEPARATOR = "#";
+
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings("unchecked")
+ public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException
+ {
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException
+ {
+ return this;
+ }
+
+ public Object get(Object owner) throws HibernateException
+ {
+ final CDOFeatureMapEntry cdoFeatureMapEntry = (CDOFeatureMapEntry)owner;
+ return getEStructuralFeatureAsString(cdoFeatureMapEntry);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) throws HibernateException
+ {
+ return get(owner);
+ }
+
+ public Method getMethod()
+ {
+ return null;
+ }
+
+ public String getMethodName()
+ {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class getReturnType()
+ {
+ return String.class;
+ }
+
+ public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
+ {
+ final CDOFeatureMapEntry cdoFeatureMapEntry = (CDOFeatureMapEntry)target;
+ setEStructuralFeatureFromString(cdoFeatureMapEntry, (String)value);
+ }
+
+ /**
+ * Set the EStructuralFeature (see {@link #setEStructuralFeature(EStructuralFeature)}) from its String representation.
+ *
+ * @param eFeatureURI
+ * a String representation, must be created by the {@link #getEStructuralFeatureAsString()} method
+ * @see #getEStructuralFeatureAsString()
+ */
+ private void setEStructuralFeatureFromString(CDOFeatureMapEntry fmEntry, String eFeatureURI)
+ {
+ final int firstSeparator = eFeatureURI.indexOf(EFEATURE_SEPARATOR);
+ final int lastSeparator = eFeatureURI.lastIndexOf(EFEATURE_SEPARATOR);
+ if (firstSeparator == -1 || lastSeparator == -1 || firstSeparator == lastSeparator)
+ {
+ throw new IllegalArgumentException("EFeature URI " + eFeatureURI + " has an illegal format");
+ }
+
+ final String ePackageURI = eFeatureURI.substring(0, firstSeparator);
+ final String eClassName = eFeatureURI.substring(1 + firstSeparator, lastSeparator);
+ final String eFeatureName = eFeatureURI.substring(1 + lastSeparator);
+
+ final HibernateCommitContext hbCommitContext = HibernateThreadContext.getCommitContext();
+ final EPackage ePackage = hbCommitContext.getCommitContext().getPackageRegistry().getEPackage(ePackageURI);
+ if (ePackage == null)
+ {
+ throw new IllegalArgumentException("EPackage not found using " + eFeatureURI + " and EPackageURI: " + ePackageURI);
+ }
+
+ final EClass eClass = (EClass)ePackage.getEClassifier(eClassName);
+ if (eClass == null)
+ {
+ throw new IllegalArgumentException("EClass not found using " + eFeatureURI + " and EClass name " + eClassName);
+ }
+
+ final EStructuralFeature eFeature = eClass.getEStructuralFeature(eFeatureName);
+ if (eFeature == null)
+ {
+ throw new IllegalArgumentException("EClass not found using " + eFeatureURI + ", EClass name " + eClassName
+ + " and EFeature name " + eFeatureName);
+ }
+
+ fmEntry.setEStructuralFeature(eFeature);
+ }
+
+ /**
+ * @return a unique String version for an EStructuralFeature
+ */
+ private String getEStructuralFeatureAsString(CDOFeatureMapEntry fmEntry)
+ {
+ final EStructuralFeature eFeature = fmEntry.getEStructuralFeature();
+ final EClass eClass = eFeature.getEContainingClass();
+ return eClass.getEPackage().getNsURI() + EFEATURE_SEPARATOR + eClass.getName() + EFEATURE_SEPARATOR
+ + eFeature.getName();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryInstantiator.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryInstantiator.java new file mode 100644 index 0000000000..57ee437f08 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryInstantiator.java @@ -0,0 +1,52 @@ +/**
+ * Copyright (c) 2004 - 2009 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 - initial api
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+
+import org.hibernate.mapping.Component;
+import org.hibernate.tuple.Instantiator;
+
+import java.io.Serializable;
+
+/**
+ * Instantiates {@link CDOFeatureMapEntry}.
+ *
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ * @version $Revision: 1.1 $
+ */
+
+public class FeatureMapEntryInstantiator implements Instantiator
+{
+ private static final long serialVersionUID = -1219767393020090471L;
+
+ public FeatureMapEntryInstantiator(Component component)
+ {
+ }
+
+ public Object instantiate()
+ {
+ final CDOFeatureMapEntry fme = CDORevisionUtil.createCDOFeatureMapEntry();
+ return fme;
+ }
+
+ public Object instantiate(Serializable id)
+ {
+ return instantiate();
+ }
+
+ public boolean isInstance(Object object)
+ {
+ return CDOFeatureMapEntry.class.isInstance(object);
+ }
+}
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 new file mode 100644 index 0000000000..b7af477f57 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryPropertyHandler.java @@ -0,0 +1,105 @@ +/**
+ * Copyright (c) 2004 - 2009 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 - initial api
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+
+import org.hibernate.HibernateException;
+import org.hibernate.PropertyNotFoundException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.property.Getter;
+import org.hibernate.property.PropertyAccessor;
+import org.hibernate.property.Setter;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * Implements the Hibernate accessor for mapped feature map properties. The owner object is always an instance of the
+ * {@link CDOFeatureMapEntry}. Returns null if the mapped property has a different name then the current feature of the
+ * owner (the CDOFeatureMapEntry), calls {@link CDOFeatureMapEntry#getValue()} in all other cases.
+ *
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ */
+@SuppressWarnings("unchecked")
+public class FeatureMapEntryPropertyHandler implements PropertyAccessor, Getter, Setter
+{
+ private static final long serialVersionUID = 1L;
+
+ private String propertyName;
+
+ public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException
+ {
+ return this;
+ }
+
+ public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException
+ {
+ return this;
+ }
+
+ public String getPropertyName()
+ {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName)
+ {
+ this.propertyName = propertyName;
+ }
+
+ public Object get(Object owner) throws HibernateException
+ {
+ final CDOFeatureMapEntry cdoFeatureMapEntry = (CDOFeatureMapEntry)owner;
+ if (!isApplicable(cdoFeatureMapEntry))
+ {
+ return null;
+ }
+
+ return cdoFeatureMapEntry.getValue();
+ }
+
+ public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) throws HibernateException
+ {
+ return get(owner);
+ }
+
+ public Method getMethod()
+ {
+ return null;
+ }
+
+ public String getMethodName()
+ {
+ return null;
+ }
+
+ public Class getReturnType()
+ {
+ return CDOFeatureMapEntry.class;
+ }
+
+ public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException
+ {
+ final CDOFeatureMapEntry cdoFeatureMapEntry = (CDOFeatureMapEntry)target;
+ if (value != null)
+ {
+ cdoFeatureMapEntry.setValue(value);
+ }
+ }
+
+ private boolean isApplicable(CDOFeatureMapEntry cdoFeatureMapEntry)
+ {
+ return cdoFeatureMapEntry.getEStructuralFeature().getName().equals(getPropertyName());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryTuplizer.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryTuplizer.java new file mode 100644 index 0000000000..9e7ff1129b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/FeatureMapEntryTuplizer.java @@ -0,0 +1,122 @@ +/**
+ * Copyright (c) 2004 - 2009 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 - initial api
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateConstants;
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Property;
+import org.hibernate.property.Getter;
+import org.hibernate.property.PropertyAccessor;
+import org.hibernate.property.Setter;
+import org.hibernate.tuple.Instantiator;
+import org.hibernate.tuple.component.AbstractComponentTuplizer;
+
+/**
+ * Tuplizer for feature map entries. These types are mapped using the dynamic capabilities of Hibernate.
+ *
+ * @see CDOFeatureMapEntry
+ * @see FeatureMapEntryPropertyHandler
+ * @see FeatureMapEntryFeatureURIPropertyHandler
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ * @version $Revision: 1.1 $
+ */
+
+public class FeatureMapEntryTuplizer extends AbstractComponentTuplizer
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final EStructuralFeature TEXT = XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text();
+
+ private static final EStructuralFeature CDATA = XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_CDATA();
+
+ private static final EStructuralFeature COMMENT = XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Comment();
+
+ public FeatureMapEntryTuplizer(Component component)
+ {
+ super(component);
+ }
+
+ @Override
+ protected Instantiator buildInstantiator(Component component)
+ {
+ return new FeatureMapEntryInstantiator(component);
+ }
+
+ @Override
+ protected Getter buildGetter(Component component, Property prop)
+ {
+ return getPropertyAccessor(prop, component).getGetter(component.getComponentClass(), prop.getName());
+ }
+
+ @Override
+ protected Setter buildSetter(Component component, Property prop)
+ {
+ return getPropertyAccessor(prop, component).getSetter(component.getComponentClass(), prop.getName());
+ }
+
+ protected PropertyAccessor getPropertyAccessor(Property mappedProperty, Component component)
+ {
+ if (mappedProperty.getName().compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_FEATURE) == 0)
+ {
+ return new FeatureMapEntryFeatureURIPropertyHandler();
+ }
+ else if (mappedProperty.getName().compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_COMMENT) == 0)
+ {
+ final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
+ propertyHandler.setPropertyName(COMMENT.getName());
+ return propertyHandler;
+ }
+ else if (mappedProperty.getName().compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_CDATA) == 0)
+ {
+ final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
+ propertyHandler.setPropertyName(CDATA.getName());
+ return propertyHandler;
+ }
+ else if (mappedProperty.getName().compareToIgnoreCase(CDOHibernateConstants.FEATUREMAP_PROPERTY_TEXT) == 0)
+ {
+ final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
+ propertyHandler.setPropertyName(TEXT.getName());
+ return propertyHandler;
+ }
+ else if (mappedProperty.getName().endsWith(CDOHibernateConstants.FEATUREMAP_PROPERTY_ANY_PRIMITIVE))
+ {
+ final WildCardAttributePropertyHandler propertyHandler = new WildCardAttributePropertyHandler();
+ final int index = mappedProperty.getName().lastIndexOf("_");
+ final String propName = mappedProperty.getName().substring(0, index);
+ propertyHandler.setPropertyName(propName);
+ return propertyHandler;
+ }
+ else if (mappedProperty.getName().endsWith(CDOHibernateConstants.FEATUREMAP_PROPERTY_ANY_REFERENCE))
+ {
+ final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
+ final int index = mappedProperty.getName().lastIndexOf("_");
+ final String propName = mappedProperty.getName().substring(0, index);
+ propertyHandler.setPropertyName(propName);
+ return propertyHandler;
+ }
+
+ final FeatureMapEntryPropertyHandler propertyHandler = new FeatureMapEntryPropertyHandler();
+ propertyHandler.setPropertyName(mappedProperty.getName());
+ return propertyHandler;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class getMappedClass()
+ {
+ return CDOFeatureMapEntry.class;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java index 8356af0df9..6d1b60a8ad 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/HibernateMoveableListWrapper.java @@ -1,10 +1,10 @@ /** - * Copyright (c) 2008 - 2008 Martin Taal and others + * Copyright (c) 2004 - 2009 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 - initial api * Eike Stepper - maintenance diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java index 3d623f9324..71eaf236c5 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/PersistableListHolder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004 - 2009 Martin Taal and others. and others + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WildCardAttributePropertyHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WildCardAttributePropertyHandler.java new file mode 100644 index 0000000000..97a053cc66 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WildCardAttributePropertyHandler.java @@ -0,0 +1,66 @@ +/**
+ * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. 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 - copied from CDORevisionPropertyHandler and adapted
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+
+import java.util.Map;
+
+/**
+ * Implements the getter/setter for a wild card EAttribute property. This type of property is used in a feature map
+ * created for wild cards. This class implements both the getter, setter and propertyaccessor interfaces. When the
+ * getGetter and getSetter methods are called it returns itself.
+ *
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ */
+@SuppressWarnings("unchecked")
+public class WildCardAttributePropertyHandler extends FeatureMapEntryPropertyHandler
+{
+ private static final long serialVersionUID = -2659637883475733107L;
+
+ @Override
+ public Object get(Object owner) throws HibernateException
+ {
+ final FeatureMap.Entry fme = (FeatureMap.Entry)owner;
+ final Object value = fme.getValue();
+ final EStructuralFeature eFeature = fme.getEStructuralFeature();
+ // not handled by this one
+ if (value instanceof EObject)
+ {
+ return null;
+ }
+
+ if (value == null)
+ {
+ return null;
+ }
+
+ final EAttribute eAttribute = (EAttribute)eFeature;
+ final EDataType eDataType = eAttribute.getEAttributeType();
+ final String valueString = eDataType.getEPackage().getEFactoryInstance().convertToString(eDataType, value);
+ return valueString;
+ }
+
+ @Override
+ public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) throws HibernateException
+ {
+ final Object value = get(owner);
+ return value;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java index 0c236ee02b..a95797af0c 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008 - 2009 Martin Taal and others. + * Copyright (c) 2004 - 2009 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 |