diff options
author | Martin Taal | 2013-09-09 14:09:18 -0400 |
---|---|---|
committer | Martin Taal | 2013-09-09 14:09:18 -0400 |
commit | a232f6e7dcca9706ea963ba6f6c3a1bdd26bcea1 (patch) | |
tree | 83bfa135437aad86823032b175483484eb64792f /plugins/org.eclipse.emf.cdo.tests.hibernate | |
parent | d71a8eea08c32e4a355baad3a756127cf3e9e6bb (diff) | |
download | cdo-a232f6e7dcca9706ea963ba6f6c3a1bdd26bcea1.tar.gz cdo-a232f6e7dcca9706ea963ba6f6c3a1bdd26bcea1.tar.xz cdo-a232f6e7dcca9706ea963ba6f6c3a1bdd26bcea1.zip |
[414828] - [Hibernate] Implement Chunked reader
Change-Id: I7531aeef66d3e3836b0bcce48c058269eb16cc12
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.hibernate')
21 files changed, 965 insertions, 261 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.pde.prefs b/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.pde.prefs index fe01bb701d..c6b96bb45e 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.pde.prefs +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/.settings/org.eclipse.pde.prefs @@ -9,7 +9,7 @@ compilers.p.build.missing.output=2 compilers.p.build.output.library=1 compilers.p.build.source.library=1 compilers.p.build.src.includes=1 -compilers.p.deprecated=2 +compilers.p.deprecated=1 compilers.p.discouraged-class=1 compilers.p.internal=1 compilers.p.missing-packages=1 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 c35d114db6..a14d128143 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,8 +20,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.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.1.100";x-friends:="org.eclipse.emf.cdo.tests.hudson", - org.eclipse.emf.cdo.tests.hibernate;version="4.1.200";x-friends:="org.eclipse.emf.cdo.tests.hudson", +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", org.eclipse.emf.cdo.tests.hibernate.model.HibernateTest.util;version="4.1.200" diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/build.properties b/plugins/org.eclipse.emf.cdo.tests.hibernate/build.properties index 7b11911fe5..731ef791f3 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/build.properties +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/build.properties @@ -20,7 +20,10 @@ bin.includes = META-INF/,\ about.ini,\ about.mappings,\ about.properties,\ - modeling32.png + modeling32.png,\ + src/log4j.properties,\ + src/app.properties,\ + src/org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml src.includes = about.html,\ copyright.txt,\ CDO AllTests (Hibernate).launch,\ 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 0d6dc563cd..1ecf9eb2a7 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/app.properties @@ -1,9 +1,14 @@ +# Teneo options +teneo.mapping.set_proxy=true +teneo.mapping.cascade_policy_on_non_containment=PERSIST,MERGE +teneo.mapping.persistence_xml.parse.lenient=true +teneo.runtime.elist_efficient_size_operation=true + +# Hibernate options hibernate.hbm2ddl.auto=create-drop hibernate.show_sql=false hibernate.connection.pool_size=10 -teneo.mapping.set_proxy=true - # ----------------------------------------------------------- # DEFAULT SETTINGS FOR IN MEMORY HSQLDB DATABASE. # @@ -27,7 +32,4 @@ hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider #hibernate.connection.url=jdbc:mysql://localhost:3306/cdohibernate #hibernate.connection.username=root #hibernate.connection.password=root -#hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect - -teneo.mapping.cascade_policy_on_non_containment=PERSIST,MERGE -teneo.mapping.persistence_xml.parse.lenient=true
\ No newline at end of file +#hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/mappings/product.hbm.xml b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/mappings/product.hbm.xml deleted file mode 100644 index 174d68a56f..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/mappings/product.hbm.xml +++ /dev/null @@ -1,218 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping auto-import="false"> - <class entity-name="Address" abstract="false" lazy="false" discriminator-value="Address" table="`address`"> - <meta attribute="eclassName">Address</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> - <meta attribute="syntheticId">true</meta> - <generator class="native"/> - </id> - <discriminator column="`dtype`" type="string"/> - <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> - <meta attribute="syntheticVersion">true</meta> - </version> - <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> - <column not-null="false" unique="false" name="`name`"/> - </property> - <property name="street" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> - <column not-null="false" unique="false" name="`street`"/> - </property> - <property name="city" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> - <column not-null="false" unique="false" name="`city`"/> - </property> - </class> - <subclass entity-name="Company" abstract="false" lazy="false" extends="Address" discriminator-value="Company"> - <meta attribute="eclassName">Company</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <list name="categories" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="company_categories"> - <column name="`company_categories_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`company_categories_idx`"/> - <one-to-many entity-name="Category"/> - </list> - <list name="suppliers" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="company_suppliers"> - <column name="`company_suppliers_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`company_suppliers_idx`"/> - <one-to-many entity-name="Supplier"/> - </list> - <list name="customers" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="company_customers"> - <column name="`company_customers_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`company_customers_idx`"/> - <one-to-many entity-name="Customer"/> - </list> - <list name="purchaseOrders" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="company_purchaseorders"> - <column name="`company_purchaseorders_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`company_purchaseorders_idx`"/> - <one-to-many entity-name="PurchaseOrder"/> - </list> - <list name="salesOrders" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="company_salesorders"> - <column name="`company_salesorders_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`company_salesorders_idx`"/> - <one-to-many entity-name="SalesOrder"/> - </list> - </subclass> - <subclass entity-name="Supplier" abstract="false" lazy="false" extends="Address" discriminator-value="Supplier"> - <meta attribute="eclassName">Supplier</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <list name="purchaseOrders" lazy="true"> - <key update="true"> - <column name="`purchaseorder_supplier_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`supplier_purchaseorders_idx`"/> - <one-to-many entity-name="PurchaseOrder"/> - </list> - </subclass> - <subclass entity-name="Customer" abstract="false" lazy="false" extends="Address" discriminator-value="Customer"> - <meta attribute="eclassName">Customer</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <list name="salesOrders" lazy="true"> - <key update="true"> - <column name="`salesorder_customer_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`customer_salesorders_idx`"/> - <one-to-many entity-name="SalesOrder"/> - </list> - </subclass> - <class entity-name="Order" abstract="false" lazy="false" discriminator-value="Order" table="`order`"> - <meta attribute="eclassName">Order</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> - <meta attribute="syntheticId">true</meta> - <generator class="native"/> - </id> - <discriminator column="`dtype`" type="string"/> - <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> - <meta attribute="syntheticVersion">true</meta> - </version> - <list name="orderDetails" lazy="true" cascade="all,delete-orphan"> - <key update="true"> - <column name="`orderdetail_order_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`order_orderdetails_idx`"/> - <one-to-many entity-name="OrderDetail"/> - </list> - </class> - <class entity-name="OrderDetail" abstract="false" lazy="false" discriminator-value="OrderDetail" table="`orderdetail`"> - <meta attribute="eclassName">OrderDetail</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> - <meta attribute="syntheticId">true</meta> - <generator class="native"/> - </id> - <discriminator column="`dtype`" type="string"/> - <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> - <meta attribute="syntheticVersion">true</meta> - </version> - <many-to-one name="order" entity-name="Order" foreign-key="orderdetail_order" lazy="false" insert="false" update="false" not-null="false"> - <column not-null="false" unique="false" name="`orderdetail_order_e_id`"/> - </many-to-one> - <many-to-one name="product" entity-name="Product" foreign-key="orderdetail_product" lazy="false" insert="false" update="false" not-null="false"> - <column not-null="false" unique="false" name="`orderdetail_product_e_id`"/> - </many-to-one> - <property name="price" lazy="false" insert="true" update="true" not-null="false" unique="false" type="float"> - <column not-null="false" unique="false" name="`price`"/> - </property> - </class> - <subclass entity-name="PurchaseOrder" abstract="false" lazy="false" extends="Order" discriminator-value="PurchaseOrder"> - <meta attribute="eclassName">PurchaseOrder</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <property name="date" lazy="false" insert="true" update="true" not-null="false" unique="false" type="timestamp"> - <column not-null="false" unique="false" name="`date`"/> - </property> - <many-to-one name="supplier" entity-name="Supplier" foreign-key="purchaseorder_supplier" lazy="false" insert="false" update="false" not-null="false"> - <column not-null="false" unique="false" name="`purchaseorder_supplier_e_id`"/> - </many-to-one> - </subclass> - <subclass entity-name="SalesOrder" abstract="false" lazy="false" extends="Order" discriminator-value="SalesOrder"> - <meta attribute="eclassName">SalesOrder</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <property name="id" lazy="false" insert="true" update="true" not-null="false" unique="false" type="int"> - <column not-null="false" unique="false" name="`id`"/> - </property> - <many-to-one name="customer" entity-name="Customer" foreign-key="salesorder_customer" lazy="false" insert="false" update="false" not-null="false"> - <column not-null="false" unique="false" name="`salesorder_customer_e_id`"/> - </many-to-one> - </subclass> - <class entity-name="Category" abstract="false" lazy="false" discriminator-value="Category" table="`category`"> - <meta attribute="eclassName">Category</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> - <meta attribute="syntheticId">true</meta> - <generator class="native"/> - </id> - <discriminator column="`dtype`" type="string"/> - <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> - <meta attribute="syntheticVersion">true</meta> - </version> - <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> - <column not-null="false" unique="false" name="`name`"/> - </property> - <list name="categories" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="category_categories"> - <column name="`category_categories_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`category_categories_idx`"/> - <one-to-many entity-name="Category"/> - </list> - <list name="products" lazy="true" cascade="all,delete-orphan"> - <key update="true" foreign-key="category_products"> - <column name="`category_products_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`category_products_idx`"/> - <one-to-many entity-name="Product"/> - </list> - </class> - <class entity-name="Product" abstract="false" lazy="false" discriminator-value="Product" table="`product`"> - <meta attribute="eclassName">Product</meta> - <meta attribute="epackage">http://www.eclipse.org/emf/CDO/tests/model1/1.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"/> - <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> - <meta attribute="syntheticId">true</meta> - <generator class="native"/> - </id> - <discriminator column="`dtype`" type="string"/> - <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> - <meta attribute="syntheticVersion">true</meta> - </version> - <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String"> - <column not-null="false" unique="false" name="`name`"/> - </property> - <list name="orderDetails" lazy="true"> - <key update="true"> - <column name="`orderdetail_product_e_id`" not-null="false" unique="false"/> - </key> - <list-index column="`product_orderdetails_idx`"/> - <one-to-many entity-name="OrderDetail"/> - </list> - </class> -</hibernate-mapping> 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 71e0f44a03..a545218506 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 @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.tests.AllConfigs; import org.eclipse.emf.cdo.tests.AttributeTest; import org.eclipse.emf.cdo.tests.BackupTest; import org.eclipse.emf.cdo.tests.CommitInfoTest; +import org.eclipse.emf.cdo.tests.CrossReferenceTest; import org.eclipse.emf.cdo.tests.DynamicXSDTest; import org.eclipse.emf.cdo.tests.EMFCompareTest; import org.eclipse.emf.cdo.tests.ExternalReferenceTest; @@ -44,9 +45,13 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_351393_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_352204_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_359966_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_362270_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_362270b_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_362270c_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_365832_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_381472_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_390185_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_400236_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_405191_Test; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; @@ -78,12 +83,13 @@ public class AllTestsHibernate extends AllConfigs protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) { // testClasses.clear(); - // testClasses.add(HibernateBugzilla_380987_Test.class); + // testClasses.add(HibernateQueryTest.class); // if (true) // { // return; // } + testClasses.add(HibernateChunkingTest.class); testClasses.add(Hibernate_Failure_Test.class); testClasses.add(Hibernate_Export_Test.class); testClasses.add(HibernateBugzilla_381013_Test.class); @@ -92,8 +98,6 @@ public class AllTestsHibernate extends AllConfigs testClasses.add(HibernateBugzilla_387752_Test.class); testClasses.add(HibernateBugzilla_387752_True_Test.class); - // testClasses.add(HibernateBugzilla_387752_Test.class); - testClasses.add(HibernateBugzilla_333473_Test.class); testClasses.add(HibernateTimeStampTest.class); @@ -104,14 +108,27 @@ public class AllTestsHibernate extends AllConfigs testClasses.add(HibernateQueryNoCachingTest.class); testClasses.add(HibernateBugzilla_301104_Test.class); - testClasses.add(HibernateBugzilla_362270_Test.class); - super.initTestClasses(testClasses, scenario); + // remove as it tries to persist an eannotation + testClasses.remove(Bugzilla_400236_Test.class); + + testClasses.add(HibernateBugzilla_362270b_Test.class); + testClasses.remove(Bugzilla_362270b_Test.class); + + testClasses.add(HibernateBugzilla_362270c_Test.class); + testClasses.remove(Bugzilla_362270c_Test.class); + + testClasses.add(HibernateBugzilla_405191_Test.class); + testClasses.remove(Bugzilla_405191_Test.class); + // for some reason this test needs to be done first... testClasses.remove(Bugzilla_306998_Test.class); testClasses.add(0, Bugzilla_306998_Test.class); + testClasses.remove(CrossReferenceTest.class); + testClasses.add(HibernateCrossReferenceTest.class); + testClasses.add(HibernateBugzilla_356181_Test.class); // the hb store throws an error on deadlocked transaction @@ -123,6 +140,9 @@ public class AllTestsHibernate extends AllConfigs if (scenario.getCapabilities().contains(IRepositoryConfig.CAPABILITY_AUDITING)) { + // need to add additional auditing annotations + testClasses.remove(HibernateBugzilla_405191_Test.class); + testClasses.add(HibernateBugzilla_395684_Test.class); testClasses.add(CDOObjectHistoryTest.class); @@ -311,7 +331,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"; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; 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/AllTestsHibernate.java.orig b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java.orig new file mode 100644 index 0000000000..71e0f44a03 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java.orig @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2008-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: + * Eike Stepper - initial API and implementation + */ +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.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.FeatureMapTest; +import org.eclipse.emf.cdo.tests.LockingManagerRestartRepositoryTest; +import org.eclipse.emf.cdo.tests.LockingManagerRestartSessionTest; +import org.eclipse.emf.cdo.tests.LockingManagerRestartTransactionTest; +import org.eclipse.emf.cdo.tests.LockingManagerTest; +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.PackageRegistryTest; +import org.eclipse.emf.cdo.tests.SecurityManagerTest; +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_258933_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_272861_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_279982_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303466_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_306998_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_322804_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_329254_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_334995_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_347964_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_351393_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_352204_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_359966_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_362270_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_365832_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_381472_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_390185_Test; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; +import org.eclipse.emf.cdo.tests.config.IScenario; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; +import org.eclipse.emf.cdo.util.CommitException; + +import java.util.List; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Eike Stepper + */ +public class AllTestsHibernate extends AllConfigs +{ + public static Test suite() + { + return new AllTestsHibernate().getTestSuite(); + } + + @Override + protected void initConfigSuites(TestSuite parent) + { + addScenario(parent, HibernateConfig.INSTANCE, JVM, NATIVE); + addScenario(parent, HibernateConfig.AUDIT_INSTANCE, JVM, NATIVE); + } + + @Override + protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) + { + // testClasses.clear(); + // testClasses.add(HibernateBugzilla_380987_Test.class); + // if (true) + // { + // return; + // } + + testClasses.add(Hibernate_Failure_Test.class); + testClasses.add(Hibernate_Export_Test.class); + testClasses.add(HibernateBugzilla_381013_Test.class); + testClasses.add(HibernateBugzilla_380987_Test.class); + testClasses.add(HibernateBugzilla_392653_Test.class); + testClasses.add(HibernateBugzilla_387752_Test.class); + testClasses.add(HibernateBugzilla_387752_True_Test.class); + + // testClasses.add(HibernateBugzilla_387752_Test.class); + + testClasses.add(HibernateBugzilla_333473_Test.class); + + testClasses.add(HibernateTimeStampTest.class); + // removed stalls + // testClasses.add(HibernateXATransactionTest.class); + testClasses.add(HibernateExternalAnnotationTest.class); + testClasses.add(HibernateQueryTest.class); + testClasses.add(HibernateQueryNoCachingTest.class); + testClasses.add(HibernateBugzilla_301104_Test.class); + + testClasses.add(HibernateBugzilla_362270_Test.class); + + super.initTestClasses(testClasses, scenario); + + // for some reason this test needs to be done first... + testClasses.remove(Bugzilla_306998_Test.class); + testClasses.add(0, Bugzilla_306998_Test.class); + + testClasses.add(HibernateBugzilla_356181_Test.class); + + // the hb store throws an error on deadlocked transaction + // and does not block + testClasses.remove(Bugzilla_390185_Test.class); + + testClasses.add(HibernateBugzilla_398057_Test.class); + testClasses.add(HibernateBugzilla_397682_Test.class); + + if (scenario.getCapabilities().contains(IRepositoryConfig.CAPABILITY_AUDITING)) + { + testClasses.add(HibernateBugzilla_395684_Test.class); + + testClasses.add(CDOObjectHistoryTest.class); + + // the security model inherits from the ecore model + // not so well supported for now for auditing + testClasses.remove(SecurityManagerTest.class); + + // the package registry count changes when auditing + // as auditing adds epackages + testClasses.remove(PackageRegistryTest.class); + testClasses.add(HibernatePackageRegistryTest.class); + testClasses.remove(Bugzilla_303466_Test.class); + testClasses.add(Hibernate_Bugzilla_303466_Test.class); + + // feature maps are not handled correctly in CDO with auditing + testClasses.remove(FeatureMapTest.class); + } + else + { + // these testcases uses commitinfo + // only supported with auditing + testClasses.remove(Bugzilla_329254_Test.class); + testClasses.remove(Hibernate_Bugzilla_329254_Test.class); + + // Commit info only works with auditing + testClasses.remove(CommitInfoTest.class); + } + + // renaming a resource is not possible in the hibernate store. + testClasses.remove(Bugzilla_334995_Test.class); + + // repository restart is not supported in the hibernate store + // as it clears the database + testClasses.remove(Bugzilla_347964_Test.class); + + // workspaces are not supported + testClasses.remove(WorkspaceTest.class); + + testClasses.remove(DynamicXSDTest.class); + + // delete repo is not yet supported + testClasses.remove(Bugzilla_381472_Test.class); + + testClasses.remove(Bugzilla_362270_Test.class); + + // persisting models in a resource is not supported + testClasses.remove(Bugzilla_365832_Test.class); + testClasses.remove(Bugzilla_352204_Test.class); + testClasses.remove(Bugzilla_359966_Test.class); + + // external reference in a resource not supported + testClasses.remove(Bugzilla_351393_Test.class); + + // hibernate does not support persisting + // java class and object + testClasses.add(HibernateAttributeTest.class); + testClasses.remove(AttributeTest.class); + + // Use a hibernate specific test class + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=339492 + testClasses.add(Hibernate_BackupTest.class); + testClasses.remove(BackupTest.class); + + // Teneo does not yet support lists of int arrays: + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330212 + testClasses.remove(Bugzilla_322804_Test.class); + + // overridden because Hibernate will treat all stale references as an exception + testClasses.add(Hibernate_Bugzilla_279982_Test.class); + testClasses.remove(Bugzilla_279982_Test.class); + + // locking not supported + testClasses.remove(LockingManagerRestartRepositoryTest.class); + testClasses.remove(LockingManagerRestartSessionTest.class); + testClasses.remove(LockingManagerRestartTransactionTest.class); + testClasses.remove(LockingNotificationsTest.class); + testClasses.remove(LockingManagerRestartRepositoryTest.class); + + // Locking manager not supported + testClasses.remove(LockingManagerTest.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 + // testListOfInteger which has a List with a null value + // this is not nicely supported by Hibernate + // therefore this step is removed + testClasses.add(HibernateMultiValuedOfAttributeTest.class); + testClasses.remove(MultiValuedOfAttributeTest.class); + + // MemStore is not relevant + testClasses.remove(MEMStoreQueryTest.class); + + // replace test case to do external mapping + testClasses.remove(XATransactionTest.class); + + // replace test case with one, disabling some non working testcases + // see the HibernateExternalReferenceTest for a description + testClasses.add(HibernateExternalReferenceTest.class); + testClasses.remove(ExternalReferenceTest.class); + + // this testcases removes and creates a resource with the + // same path in one transaction, that's not supported + // by hibernate.. because of unique key constraints + testClasses.remove(Bugzilla_272861_Test.class); + + // override a testcase because the hibernate store + // has a different meaning of unset + testClasses.add(HibernateBugzilla_258933_Test.class); + testClasses.remove(Bugzilla_258933_Test.class); + + // replace as unsettable has to be re-visited for the hb store + // see Bug 298579, it does not work for object types + testClasses.add(HibernateUnsetTest.class); + testClasses.remove(UnsetTest.class); + } + + /** + * Overridden because one testcase does not pass as Hibernate currently does not store the isset boolean values in the + * database. + * + * @author Eike Stepper + */ + public static class HibernateUnsetTest extends UnsetTest + { + @Override + public void testUnsettableBaseTypeVsObjectType() + { + } + } + + public static class HibernatePackageRegistryTest extends PackageRegistryTest + { + + @Override + public void testCommitNestedPackages() throws Exception + { + } + + @Override + public void testCommitTopLevelPackages() throws Exception + { + } + } + + // overridden because Hibernate will treat all stale references as an exception + public static class Hibernate_Bugzilla_279982_Test extends Bugzilla_279982_Test + { + @Override + public void testBugzilla_279982_Single() throws Exception + { + try + { + super.testBugzilla_279982_Single(); + } + catch (Exception e) + { + assertEquals(true, e instanceof CommitException); + assertEquals(true, e.getMessage().contains("org.hibernate.ObjectNotFoundException")); + } + } + + @Override + public void testBugzilla_279982_Multi_RevisionPrefetchingPolicy() throws Exception + { + try + { + super.testBugzilla_279982_Multi_RevisionPrefetchingPolicy(); + } + catch (Exception e) + { + assertEquals(true, e instanceof CommitException); + assertEquals(true, e.getMessage().contains("org.hibernate.ObjectNotFoundException")); + } + } + } + + public static class Hibernate_BackupTest extends BackupTest + { + + @Override + protected void doSetUp() throws Exception + { + 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(HibernateStore.PERSISTENCE_XML, persistenceXML); + + super.doSetUp(); + } + + @Override + protected void doTearDown() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + hbConfig.getAdditionalProperties().clear(); + super.doTearDown(); + } + } + + public static class Hibernate_Bugzilla_303466_Test extends Bugzilla_303466_Test + { + + @Override + public void test_missingDependency() throws Exception + { + } + + } + + public static class Hibernate_Bugzilla_329254_Test extends Bugzilla_329254_Test + { + + // does not work for non audited cases + @Override + public void testCommitTimeStampUpdateOnError() 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_362270b_Test.java index 86899a6cfb..894fb053fb 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_362270b_Test.java @@ -11,7 +11,7 @@ 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.bugzilla.Bugzilla_362270b_Test; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; /** @@ -19,34 +19,15 @@ import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; * * @author Martin Taal */ -public class HibernateBugzilla_362270_Test extends ExternalReferenceTest +public class HibernateBugzilla_362270b_Test extends Bugzilla_362270b_Test { - @Override - public void testOneXMIResourceManyViewsOnOneResourceSet() throws Exception - { - } - - @Override - public void testUsingObjectsBetweenSameTransaction() throws Exception - { - } - - @Override - public void testManyViewsOnOneResourceSet() throws Exception - { - } - - @Override - public void testXRefExternalObject() throws Exception - { - } @Override protected void doSetUp() throws Exception { final IRepositoryConfig repConfig = getRepositoryConfig(); final HibernateConfig hbConfig = (HibernateConfig)repConfig; - final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml"; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; 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/HibernateBugzilla_362270c_Test.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_362270c_Test.java new file mode 100644 index 0000000000..922d5397d9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_362270c_Test.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012 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.server.internal.hibernate.HibernateStore; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_362270c_Test; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; + +/** + * Read external reference annotation. + * + * @author Martin Taal + */ +public class HibernateBugzilla_362270c_Test extends Bugzilla_362270c_Test +{ + + @Override + protected void doSetUp() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); + + super.doSetUp(); + } + + @Override + protected void doTearDown() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + hbConfig.getAdditionalProperties().clear(); + super.doTearDown(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_387752_Test.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_387752_Test.java index 059d876b1e..d519ebfe48 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_387752_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_387752_Test.java @@ -59,7 +59,7 @@ public class HibernateBugzilla_387752_Test extends AbstractCDOTest CDOSession session = openSession(); CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource(getResourcePath("/test1")); + CDOResource resource = transaction.getResource(getResourcePath("/test1")); Bz387752_Main main = HibernateTestFactory.eINSTANCE.createBz387752_Main(); main.setEnumSettable(null); diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_392653_Test.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_392653_Test.java index aa83bf7920..48581a4e65 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_392653_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_392653_Test.java @@ -61,7 +61,7 @@ public class HibernateBugzilla_392653_Test extends AbstractCDOTest CDOTransaction transaction2 = session2.openTransaction(); // Read all repo contents - TreeIterator<EObject> iter = transaction2.getRootResource().getAllContents(); + TreeIterator<EObject> iter = transaction2.getResource(getResourcePath("/")).getAllContents(); while (iter.hasNext()) { iter.next(); diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_405191_Test.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_405191_Test.java new file mode 100644 index 0000000000..5023118e61 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateBugzilla_405191_Test.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012 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.server.internal.hibernate.HibernateStore; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_405191_Test; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; + +/** + * @author Martin Taal + */ +public class HibernateBugzilla_405191_Test extends Bugzilla_405191_Test +{ + + @Override + protected void doSetUp() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); + + super.doSetUp(); + } + + @Override + protected void doTearDown() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + hbConfig.getAdditionalProperties().clear(); + super.doTearDown(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateChunkingTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateChunkingTest.java new file mode 100644 index 0000000000..ff0667d759 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateChunkingTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2007-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: + * Eike Stepper - initial API and implementation + * Martin Taal - Changes for hibernate + */ +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.model1.Company; +import org.eclipse.emf.cdo.tests.model1.Customer; +import org.eclipse.emf.cdo.tests.model1.SalesOrder; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.net4j.util.io.IOUtil; + +import org.eclipse.emf.common.util.EList; + +import java.util.Iterator; + +/** + * @author Eike Stepper + */ +public class HibernateChunkingTest extends AbstractCDOTest +{ + public void testReadNative() throws Exception + { + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath("/test1")); + + Company company = getModel1Factory().createCompany(); + company.setName("company"); + resource.getContents().add(company); + + for (int i = 0; i < 100; i++) + { + SalesOrder salesOrder = getModel1Factory().createSalesOrder(); + salesOrder.setId(i); + company.getSalesOrders().add(salesOrder); + } + + transaction.commit(); + session.close(); + } + + clearCache(getRepository().getRevisionManager()); + + CDOSession session = openSession(); + session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(10, 10)); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(getResourcePath("/test1")); + + Company company = (Company)resource.getContents().get(0); + EList<SalesOrder> salesOrders = company.getSalesOrders(); + int i = 0; + for (Iterator<SalesOrder> it = salesOrders.iterator(); it.hasNext();) + { + IOUtil.OUT().println(i++); + SalesOrder salesOrder = it.next(); + IOUtil.OUT().println(salesOrder); + } + } + + public void testWriteNative() throws Exception + { + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath("/test1")); + + Customer customer = getModel1Factory().createCustomer(); + customer.setName("customer"); + resource.getContents().add(customer); + + for (int i = 0; i < 100; i++) + { + SalesOrder salesOrder = getModel1Factory().createSalesOrder(); + salesOrder.setId(i); + salesOrder.setCustomer(customer); + resource.getContents().add(salesOrder); + } + + transaction.commit(); + session.close(); + } + + clearCache(getRepository().getRevisionManager()); + + CDOSession session = openSession(); + session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(10, 10)); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(getResourcePath("/test1")); + + Customer customer = (Customer)resource.getContents().get(0); + EList<SalesOrder> salesOrders = customer.getSalesOrders(); + for (int i = 50; i < 70; i++) + { + SalesOrder salesOrder = getModel1Factory().createSalesOrder(); + salesOrder.setId(i + 1000); + resource.getContents().add(salesOrder); + salesOrders.set(i, salesOrder); + } + + transaction.commit(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateCrossReferenceTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateCrossReferenceTest.java new file mode 100644 index 0000000000..efb1fd6bfc --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateCrossReferenceTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2009, 2011, 2012 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.server.internal.hibernate.HibernateStore; +import org.eclipse.emf.cdo.tests.CrossReferenceTest; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; + +/** + * Tests with a separate annotations.xml. + * + * @author Martin Taal + */ +public class HibernateCrossReferenceTest extends CrossReferenceTest +{ + + @Override + protected void doSetUp() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; + hbConfig.getAdditionalProperties().put(HibernateStore.PERSISTENCE_XML, persistenceXML); + + super.doSetUp(); + } + + @Override + protected void doTearDown() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + hbConfig.getAdditionalProperties().clear(); + super.doTearDown(); + } +} 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 98c7a64897..728ca46147 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 @@ -48,7 +48,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"; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; 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 cf867c4c39..a72c1cfdca 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 @@ -62,7 +62,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"; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; 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.orig b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalReferenceTest.java.orig new file mode 100644 index 0000000000..cf867c4c39 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateExternalReferenceTest.java.orig @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2009, 2011, 2012 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.server.internal.hibernate.HibernateStore; +import org.eclipse.emf.cdo.tests.ExternalReferenceTest; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; + +/** + * Test {@link ExternalReferenceTest}, disables some testcases which will never work anyway. + * + * @author Martin Taal + */ +public class HibernateExternalReferenceTest extends ExternalReferenceTest +{ + + @Override + public void testXRefExternalObject() throws Exception + { + // xreffing an external object is not possible as the + // external reference does not hold type information + } + + @Override + public void testManyViewsOnOneResourceSet() throws Exception + { + // this testcase does not work because it there are external temporary references between two + // objects and the objects are stored at the same time. The temporary references are then + // stored in the database (as external), when retrieving the objects the temporary references + // can not be resolved to real ones. + // one note in the second part of the test the supplier is read. The supplier is not read + // from the database but is cached server side + // super.testManyViewsOnOneResourceSet(); + } + + @Override + public void testUsingObjectsBetweenSameTransaction() throws Exception + { + // note this testcase requires that no id's are mapped externally + // this testcase does not work for hibernate because 2 objects reference eachother and + // are added in different transactions, hibernate/mysql will throw a fk-constraint + // exception. This is correct behavior. + // super.testUsingObjectsBetweenSameTransaction(); + } + + @Override + public void testOneXMIResourceManyViewsOnOneResourceSet() + { + + } + + @Override + protected void doSetUp() throws Exception + { + 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(HibernateStore.PERSISTENCE_XML, persistenceXML); + + super.doSetUp(); + } + + @Override + protected void doTearDown() throws Exception + { + final IRepositoryConfig repConfig = getRepositoryConfig(); + final HibernateConfig hbConfig = (HibernateConfig)repConfig; + hbConfig.getAdditionalProperties().clear(); + super.doTearDown(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateLazyLoadTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateLazyLoadTest.java new file mode 100644 index 0000000000..f6eed9d92f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateLazyLoadTest.java @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2009-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.server.hibernate.IHibernateStore; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.model1.Customer; +import org.eclipse.emf.cdo.tests.model1.Order; +import org.eclipse.emf.cdo.tests.model1.OrderDetail; +import org.eclipse.emf.cdo.tests.model1.Product1; +import org.eclipse.emf.cdo.tests.model1.SalesOrder; +import org.eclipse.emf.cdo.tests.model1.Supplier; +import org.eclipse.emf.cdo.tests.model1.VAT; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CommitException; +import org.eclipse.emf.cdo.view.CDOQuery; + +import org.eclipse.net4j.util.WrappedException; + +import java.util.ArrayList; +import java.util.List; + +/** + * Test lazy load behavior of hibernate + * + * @author Martin Taal + */ +public class HibernateLazyLoadTest extends AbstractCDOTest +{ + private static final int NUM_OF_PRODUCTS = 10; + + private static final int NUM_OF_CUSTOMERS = 2; + + private static final int NUM_OF_PRODUCTS_CUSTOMER = NUM_OF_PRODUCTS / NUM_OF_CUSTOMERS; + + private static final int NUM_OF_SALES_ORDERS = 5; + + private static final int NUM_OF_SUPPLIERS = 5; + + @Override + public void doSetUp() throws Exception + { + org.eclipse.emf.cdo.tests.model1.Model1Package.eINSTANCE.getSupplier_Preferred().setLowerBound(1); + org.eclipse.emf.cdo.tests.model1.legacy.Model1Package.eINSTANCE.getSupplier_Preferred().setLowerBound(1); + super.doSetUp(); + } + + @Override + public void doTearDown() throws Exception + { + org.eclipse.emf.cdo.tests.model1.Model1Package.eINSTANCE.getSupplier_Preferred().setLowerBound(0); + org.eclipse.emf.cdo.tests.model1.legacy.Model1Package.eINSTANCE.getSupplier_Preferred().setLowerBound(0); + super.doTearDown(); + } + + public void testSimpleQueries() throws Exception + { + msg("Opening session"); + CDOSession session = openSession(); + + createTestSet(session); + + session.close(); + session = openSession(); + msg("Opening transaction for querying"); + CDOTransaction transaction = session.openTransaction(); + + clearCache(getRepository().getRevisionManager()); + + { + msg("Query for products"); + CDOQuery cdoQuery = transaction.createQuery("hql", "from SalesOrder"); + addCacheParameter(cdoQuery); + cdoQuery.setMaxResults(1); + final List<SalesOrder> orders = cdoQuery.getResult(SalesOrder.class); + System.err.println(orders.get(0).getOrderDetails().get(0).getPrice()); + System.err.println(orders.get(0).getCustomer().getName()); + assertEquals(orders.size(), 1); + } + + transaction.commit(); + enableConsole(); + } + + private void createTestSet(CDOSession session) + { + disableConsole(); + msg("Opening transaction"); + CDOTransaction transaction = session.openTransaction(); + + msg("Creating resource"); + CDOResource resource = transaction.createResource(getResourcePath("/test1")); + + fillResource(resource); + + try + { + msg("Committing"); + transaction.commit(); + } + catch (CommitException ex) + { + throw WrappedException.wrap(ex); + } + + enableConsole(); + } + + private void fillResource(CDOResource resource) + { + msg("Creating Testset"); + final List<Product1> products = new ArrayList<Product1>(); + for (int i = 0; i < NUM_OF_PRODUCTS; i++) + { + products.add(createProduct(i)); + } + + resource.getContents().addAll(products); + + int productCounter = 0; + for (int i = 0; i < NUM_OF_CUSTOMERS; i++) + { + final Customer customer = getModel1Factory().createCustomer(); + customer.setCity("City " + i); + customer.setName(i + ""); + customer.setStreet("Street " + i); + resource.getContents().add(customer); + + final List<Product1> customerProducts = products.subList(productCounter, productCounter + + NUM_OF_PRODUCTS_CUSTOMER); + for (int k = 0; k < NUM_OF_SALES_ORDERS; k++) + { + resource.getContents().add(createSalesOrder(i * 10 + k, customer, customerProducts)); + } + + productCounter += NUM_OF_PRODUCTS_CUSTOMER; + } + + final List<Supplier> suppliers = new ArrayList<Supplier>(); + for (int i = 0; i < NUM_OF_SUPPLIERS; i++) + { + suppliers.add(createSupplier(i)); + } + + resource.getContents().addAll(suppliers); + } + + private Supplier createSupplier(int i) + { + Supplier supplier = getModel1Factory().createSupplier(); + supplier.setCity("City " + i); + supplier.setName(i + ""); + supplier.setStreet("Street " + i); + // supplier.setPreferred(false); // will be persisted with its default value + return supplier; + } + + private SalesOrder createSalesOrder(int num, Customer customer, List<Product1> products) + { + SalesOrder salesOrder = getModel1Factory().createSalesOrder(); + salesOrder.setCustomer(customer); + salesOrder.setId(num); + createOrderDetail(salesOrder, num, products); + return salesOrder; + } + + private List<OrderDetail> createOrderDetail(Order order, int index, List<Product1> products) + { + final List<OrderDetail> orderDetails = new ArrayList<OrderDetail>(); + int count = 0; + for (Product1 product : products) + { + OrderDetail orderDetail = getModel1Factory().createOrderDetail(); + orderDetail.setOrder(order); + orderDetail.setPrice(count++ * index * 1.1f); + orderDetail.setProduct(product); + } + + return orderDetails; + } + + private Product1 createProduct(int index) + { + Product1 product = getModel1Factory().createProduct1(); + product.setDescription("Description " + index); + product.setName("" + index); + if (index < 10) + { + product.setVat(VAT.VAT15); + } + else + { + product.setVat(VAT.VAT7); + } + + return product; + } + + protected void addCacheParameter(CDOQuery query) + { + query.setParameter(IHibernateStore.CACHE_RESULTS, true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateQueryTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateQueryTest.java index d7176a6930..8ecaf6c17e 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateQueryTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateQueryTest.java @@ -265,6 +265,7 @@ public class HibernateQueryTest extends AbstractCDOTest orderQuery.setParameter("od", orderDetail); final List<SalesOrder> sos = orderQuery.getResult(SalesOrder.class); assertEquals(1, sos.size()); + assertNotNull(sos.get(0).getCustomer().getName()); assertEquals(orderDetail.getOrder(), sos.get(0)); } } 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 1872e434db..99823357c1 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 @@ -26,7 +26,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"; + final String persistenceXML = "org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml"; 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/external_model1_4.persistence.xml b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml index 72f7426704..d180ab06d2 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/external_model1_4.persistence.xml +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/cdo_hibernate.persistence.xml @@ -2,6 +2,21 @@ <persistence-mapping xmlns="http://www.eclipse.org/emft/teneo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <epackage namespace-uri="http://www.eclipse.org/emf/CDO/tests/model6/1.0.0"> + + <eclass name="UnsettableAttributes"> + <property name="attrJavaClass"> + <type type="string"/> + </property> + </eclass> + + <eclass name="RefSingleNonContainedNPL"> + <property name="element"> + <external>org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType</external> + </property> + </eclass> + </epackage> + <epackage namespace-uri="http://www.eclipse.org/emf/CDO/tests/model4/1.0.0"> <eclass name="GenRefSingleNonContained"> @@ -9,10 +24,21 @@ <external>org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType</external> </property> </eclass> + + <eclass name="RefSingleNonContainedNPL"> + <property name="element"> + <external>org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType</external> + </property> + </eclass> </epackage> <epackage namespace-uri="http://www.eclipse.org/emf/CDO/tests/model1/1.0.0"> + <eclass name="Company"> + <property name="customers"> + <external>org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType</external> + </property> + </eclass> <eclass name="SalesOrder"> <property name="customer"> <external>org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDExternalUserType</external> |