diff options
5 files changed, 101 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOENumStringType.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOENumStringType.java index 46f6f95805..6db6d81cf4 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOENumStringType.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOENumStringType.java @@ -63,6 +63,10 @@ public class CDOENumStringType implements UserType, ParameterizedType */ public Object assemble(Serializable cached, Object owner) throws HibernateException { + if (cached instanceof String) + { + return getEEnum().getEEnumLiteralByLiteral((String)cached); + } return cached; } @@ -81,6 +85,11 @@ public class CDOENumStringType implements UserType, ParameterizedType */ public Serializable disassemble(Object value) throws HibernateException { + if (value instanceof EEnumLiteral) + { + return ((EEnumLiteral)value).getLiteral(); + } + return (Serializable)value; } 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 ff1ca36486..188ff36ad3 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 @@ -20,7 +20,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.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)" + javax.persistence;bundle-version="[2.0.0,3.0.0)", + org.hibernate;bundle-version="[4.0.0,4.2.0)", + org.slf4j.api;bundle-version="[1.7.0,2.0.0)" Export-Package: org.eclipse.emf.cdo.tests.hibernate;version="4.1.200";x-friends:="org.eclipse.emf.cdo.tests.hudson", org.eclipse.emf.cdo.tests.hibernate.model.HibernateTest;version="4.1.200", org.eclipse.emf.cdo.tests.hibernate.model.HibernateTest.impl;version="4.1.200", 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 c1197d42c5..89282917b4 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 @@ -86,7 +86,7 @@ public class AllTestsHibernate extends AllConfigs protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) { // testClasses.clear(); - // testClasses.add(TransactionTest.class); + // testClasses.add(HibernateBugzilla_417797_Test.class); // if (true) // { // return; @@ -104,6 +104,7 @@ public class AllTestsHibernate extends AllConfigs testClasses.add(Hibernate_Failure_Test.class); testClasses.add(Hibernate_Export_Test.class); testClasses.add(HibernateBugzilla_381013_Test.class); + testClasses.add(HibernateBugzilla_417797_Test.class); testClasses.add(HibernateBugzilla_392653_Test.class); testClasses.add(HibernateBugzilla_387752_Test.class); diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_417797_Test.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_417797_Test.java new file mode 100644 index 0000000000..46c6dc9909 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_417797_Test.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2012, 2013 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 + */ +package org.eclipse.emf.cdo.tests.hibernate; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; +import org.eclipse.emf.cdo.tests.mango.MangoParameter; +import org.eclipse.emf.cdo.tests.mango.ParameterPassing; +import org.eclipse.emf.cdo.tests.mango.legacy.MangoPackage; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EcoreFactory; + +import org.hibernate.cache.ehcache.EhCacheRegionFactory; +import org.hibernate.cfg.Environment; + +/** + * + * @author Martin Taal + */ +public class HibernateBugzilla_417797_Test extends AbstractCDOTest +{ + + @Override + protected void doSetUp() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + + final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); + eAnnotation.setSource("teneo.jpa"); + eAnnotation.getDetails().put("value", "@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)"); + MangoPackage.eINSTANCE.getMangoParameter().getEAnnotations().add(eAnnotation); + + hbConfig.getAdditionalProperties().put(Environment.USE_SECOND_LEVEL_CACHE, "true"); + hbConfig.getAdditionalProperties().put(Environment.CACHE_REGION_FACTORY, EhCacheRegionFactory.class.getName()); + super.doSetUp(); + } + + @Override + protected void doTearDown() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + hbConfig.getAdditionalProperties().clear(); + super.doTearDown(); + } + + @CleanRepositoriesBefore(reason = "Start with a fresh repo") + public void testBugzilla() throws Exception + { + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath("/test1")); + + MangoParameter createMangoParameter = getMangoFactory().createMangoParameter(); + createMangoParameter.setName("Mango1"); + createMangoParameter.setPassing(ParameterPassing.BY_REFERENCE); + + resource.getContents().add(createMangoParameter); + + transaction.commit(); + session.close(); + } + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(getResourcePath("/test1")); + System.err.println(resource.getContents().get(0)); + transaction.commit(); + session.close(); + } + } +} 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 677372d118..1dc3448d37 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 @@ -60,8 +60,8 @@ public class HibernateConfig extends RepositoryConfig { final Properties teneoProperties = new Properties(); Map<String, String> additionalProperties = getAdditionalProperties(); - teneoProperties.putAll(additionalProperties); teneoProperties.load(getClass().getResourceAsStream("/app.properties")); + teneoProperties.putAll(additionalProperties); for (Object key : teneoProperties.keySet()) { props.put((String)key, teneoProperties.getProperty((String)key)); |