diff options
author | mtaal | 2009-10-02 07:23:41 +0000 |
---|---|---|
committer | mtaal | 2009-10-02 07:23:41 +0000 |
commit | 8cfbfb0afbd190017c9e2451a4a5077d221c897d (patch) | |
tree | 3b71b7f3d227d76619ca9d3717c9f64fef0fc0cb /tests | |
parent | 4e458204bd454d4b96cbcc2b327e73f3205564a0 (diff) | |
download | org.eclipse.emf.teneo-8cfbfb0afbd190017c9e2451a4a5077d221c897d.tar.gz org.eclipse.emf.teneo-8cfbfb0afbd190017c9e2451a4a5077d221c897d.tar.xz org.eclipse.emf.teneo-8cfbfb0afbd190017c9e2451a4a5077d221c897d.zip |
[290969]
Diffstat (limited to 'tests')
8 files changed, 285 insertions, 12 deletions
diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_a_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_a_o_hibernate.hbm.xml new file mode 100644 index 000000000..da27fe427 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_a_o_hibernate.hbm.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping auto-import="false"> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.BarImpl" entity-name="BarEntity" abstract="false" lazy="false" discriminator-value="BarEntity" table="`barentity`"> + <meta attribute="eclassName">Bar</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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 type="string"> + <column name="dtype" index="barentitydtype" length="255" not-null="true"/> + </discriminator> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + <list name="barKeys" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="barentity_barkeys"> + <column name="`barentity_barkeys_e_id`" not-null="false" unique="false"/> + </key> + <list-index column="`barentity_barkeys_idx`"/> + <one-to-many entity-name="BarKeyEntity"/> + </list> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.BarKeyImpl" entity-name="BarKeyEntity" abstract="false" lazy="false" discriminator-value="BarKeyEntity" table="`barkeyentity`"> + <meta attribute="eclassName">BarKey</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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 type="string"> + <column name="dtype" index="barkeyentitydtype" length="255" not-null="true"/> + </discriminator> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.FooImpl" entity-name="FooEntity" abstract="false" lazy="false" discriminator-value="FooEntity" table="`fooentity`"> + <meta attribute="eclassName">Foo</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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 type="string"> + <column name="dtype" index="fooentitydtype" length="255" not-null="true"/> + </discriminator> + <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="barKey" entity-name="BarKeyEntity" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="fooentity_barkey" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`barkeyentity_barkey_e_id`"/> + </many-to-one> + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_e_o_hibernate.hbm.xml new file mode 100644 index 000000000..04f078575 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_e_o_hibernate.hbm.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping auto-import="false"> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.BarImpl" entity-name="BarEntity" abstract="false" lazy="false" table="`barentity`"> + <meta attribute="eclassName">Bar</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + <list name="barKeys" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="barentity_barkeys"> + <column name="`barentity_barkeys_e_id`" not-null="false" unique="false"/> + </key> + <list-index column="`barentity_barkeys_idx`"/> + <one-to-many entity-name="BarKeyEntity"/> + </list> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.BarKeyImpl" entity-name="BarKeyEntity" abstract="false" lazy="false" table="`barkeyentity`"> + <meta attribute="eclassName">BarKey</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.FooImpl" entity-name="FooEntity" abstract="false" lazy="false" table="`fooentity`"> + <meta attribute="eclassName">Foo</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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> + <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="barKey" entity-name="BarKeyEntity" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="fooentity_barkey" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`barkeyentity_barkey_e_id`"/> + </many-to-one> + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_s_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_s_o_hibernate.hbm.xml new file mode 100644 index 000000000..04f078575 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/BZ290696Action_mysql_s_o_hibernate.hbm.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping auto-import="false"> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.BarImpl" entity-name="BarEntity" abstract="false" lazy="false" table="`barentity`"> + <meta attribute="eclassName">Bar</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + <list name="barKeys" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="barentity_barkeys"> + <column name="`barentity_barkeys_e_id`" not-null="false" unique="false"/> + </key> + <list-index column="`barentity_barkeys_idx`"/> + <one-to-many entity-name="BarKeyEntity"/> + </list> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.BarKeyImpl" entity-name="BarKeyEntity" abstract="false" lazy="false" table="`barkeyentity`"> + <meta attribute="eclassName">BarKey</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + </class> + <class name="org.eclipse.emf.teneo.samples.issues.bz290969.impl.FooImpl" entity-name="FooEntity" abstract="false" lazy="false" table="`fooentity`"> + <meta attribute="eclassName">Foo</meta> + <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/issues/bz290969</meta> + <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> + <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="barKey" entity-name="BarKeyEntity" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="fooentity_barkey" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`barkeyentity_barkey_e_id`"/> + </many-to-one> + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_a_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_a_o_hibernate.hbm.xml index 5c76e483c..96e41977c 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_a_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_a_o_hibernate.hbm.xml @@ -18,10 +18,10 @@ <key update="true"> <column name="`city_fk`" not-null="true" unique="false"/> </key> - <one-to-many entity-name="Street" not-found="ignore"/> + <one-to-many entity-name="Straat" not-found="ignore"/> </bag> </class> - <class name="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.impl.StreetImpl" entity-name="Street" abstract="false" lazy="true" discriminator-value="Street" table="`street`" proxy="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.Street"> + <class name="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.impl.StreetImpl" entity-name="Straat" abstract="false" lazy="true" discriminator-value="Straat" table="`straat`" proxy="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.Street"> <meta attribute="eclassName">Street</meta> <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/emf/annotations/hibernate</meta> <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> @@ -29,7 +29,7 @@ <generator class="native"/> </id> <discriminator type="string"> - <column name="dtype" index="streetdtype" length="255" not-null="true"/> + <column name="dtype" index="straatdtype" length="255" not-null="true"/> </discriminator> <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> <meta attribute="syntheticVersion">true</meta> @@ -37,7 +37,7 @@ <property name="name" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> <column not-null="true" unique="false" name="`name`"/> </property> - <many-to-one name="city" entity-name="Stad" lazy="proxy" cascade="merge,persist,save-update,lock,refresh" foreign-key="street_city" insert="true" update="true" not-null="true"> + <many-to-one name="city" entity-name="Stad" lazy="proxy" cascade="merge,persist,save-update,lock,refresh" foreign-key="straat_city" insert="true" update="true" not-null="true"> <column not-null="true" unique="false" name="`city_fk`"/> </many-to-one> </class> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_e_o_hibernate.hbm.xml index 56d759813..214627fb9 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_e_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_e_o_hibernate.hbm.xml @@ -15,10 +15,10 @@ <key update="true"> <column name="`city_fk`" not-null="true" unique="false"/> </key> - <one-to-many entity-name="Street" not-found="ignore"/> + <one-to-many entity-name="Straat" not-found="ignore"/> </bag> </class> - <class name="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.impl.StreetImpl" entity-name="Street" abstract="false" lazy="true" table="`street`" proxy="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.Street"> + <class name="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.impl.StreetImpl" entity-name="Straat" abstract="false" lazy="true" table="`straat`" proxy="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.Street"> <meta attribute="eclassName">Street</meta> <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/emf/annotations/hibernate</meta> <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> @@ -31,7 +31,7 @@ <property name="name" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> <column not-null="true" unique="false" name="`name`"/> </property> - <many-to-one name="city" entity-name="Stad" lazy="proxy" cascade="merge,persist,save-update,lock,refresh" foreign-key="street_city" insert="true" update="true" not-null="true"> + <many-to-one name="city" entity-name="Stad" lazy="proxy" cascade="merge,persist,save-update,lock,refresh" foreign-key="straat_city" insert="true" update="true" not-null="true"> <column not-null="true" unique="false" name="`city_fk`"/> </many-to-one> </class> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_s_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_s_o_hibernate.hbm.xml index 56d759813..214627fb9 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_s_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/HibernateAction_mysql_s_o_hibernate.hbm.xml @@ -15,10 +15,10 @@ <key update="true"> <column name="`city_fk`" not-null="true" unique="false"/> </key> - <one-to-many entity-name="Street" not-found="ignore"/> + <one-to-many entity-name="Straat" not-found="ignore"/> </bag> </class> - <class name="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.impl.StreetImpl" entity-name="Street" abstract="false" lazy="true" table="`street`" proxy="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.Street"> + <class name="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.impl.StreetImpl" entity-name="Straat" abstract="false" lazy="true" table="`straat`" proxy="org.eclipse.emf.teneo.samples.emf.annotations.hibernate.Street"> <meta attribute="eclassName">Street</meta> <meta attribute="epackage">http://www.eclipse.org/emf/teneo/samples/emf/annotations/hibernate</meta> <id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> @@ -31,7 +31,7 @@ <property name="name" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> <column not-null="true" unique="false" name="`name`"/> </property> - <many-to-one name="city" entity-name="Stad" lazy="proxy" cascade="merge,persist,save-update,lock,refresh" foreign-key="street_city" insert="true" update="true" not-null="true"> + <many-to-one name="city" entity-name="Stad" lazy="proxy" cascade="merge,persist,save-update,lock,refresh" foreign-key="straat_city" insert="true" update="true" not-null="true"> <column not-null="true" unique="false" name="`city_fk`"/> </many-to-one> </class> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java index 1cefd0b6f..44cc1477c 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java @@ -55,13 +55,15 @@ import org.eclipse.emf.teneo.test.emf.annotations.VariousAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.93 $ + * @version $Revision: 1.94 $ */ public class AllTests { public static Test suite() { TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.emf.annotations", HibernateTestbed.instance().getConfigurations()); + suite.addTestSuite(BZ290969Action.class); + suite.addTestSuite(HibernateAction.class); suite.addTestSuite(EAVMappingAllAction.class); suite.addTestSuite(EAVMappingAction.class); suite.addTestSuite(InheritanceAnnotationAction.class); @@ -82,7 +84,6 @@ public class AllTests { suite.addTestSuite(HbSequenceIdAction.class); - suite.addTestSuite(HibernateAction.class); suite.addTestSuite(OverrideSecondaryAction.class); suite.addTestSuite(PKeyJoinAction.class); diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/BZ290969Action.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/BZ290969Action.java new file mode 100644 index 000000000..d2c264697 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/BZ290969Action.java @@ -0,0 +1,119 @@ +/** + * <copyright> + * + * Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) 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 + * </copyright> + * + * $Id: BZ290969Action.java,v 1.1 2009/10/02 07:23:41 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.test.emf.annotations; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import org.eclipse.emf.teneo.extension.ExtensionManager; +import org.eclipse.emf.teneo.mapping.strategy.SQLNameStrategy; +import org.eclipse.emf.teneo.mapping.strategy.impl.TeneoNewSQLNameStrategy; +import org.eclipse.emf.teneo.samples.emf.annotations.hibernate.HibernateFactory; +import org.eclipse.emf.teneo.samples.issues.bz290969.Bar; +import org.eclipse.emf.teneo.samples.issues.bz290969.BarKey; +import org.eclipse.emf.teneo.samples.issues.bz290969.Bz290969Factory; +import org.eclipse.emf.teneo.samples.issues.bz290969.Bz290969Package; +import org.eclipse.emf.teneo.samples.issues.bz290969.Foo; +import org.eclipse.emf.teneo.test.AbstractTestAction; +import org.eclipse.emf.teneo.test.StoreTestException; +import org.eclipse.emf.teneo.test.stores.TestStore; + +/** + * Tests bugzilla 290969 + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.1 $ + */ +public class BZ290969Action extends AbstractTestAction { + final HibernateFactory factory = HibernateFactory.eINSTANCE; + + public BZ290969Action() { + super(Bz290969Package.eINSTANCE); + } + + /** Add extensions if you want */ + public void setExtensions(ExtensionManager extensionManager) { + extensionManager.registerExtension(SQLNameStrategy.class.getName(), TeneoNewSQLNameStrategy.class.getName()); + } + + // @Override + // public Properties getExtraConfigurationProperties() { + // final Properties props = new Properties(); + // props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE"); + // return props; + // } + + @Override + public void doAction(TestStore store) { + store.disableDrop(); + final Bz290969Factory factory = Bz290969Factory.eINSTANCE; + store.disableDrop(); + { + store.beginTransaction(); + final Bar bar = factory.createBar(); + final BarKey barKey1 = factory.createBarKey(); + final BarKey barKey2 = factory.createBarKey(); + bar.getBarKeys().add(barKey1); + bar.getBarKeys().add(barKey2); + final Foo foo = factory.createFoo(); + foo.setBarKey(barKey1); + store.store(bar); + store.store(foo); + store.commitTransaction(); + } + { + store.beginTransaction(); + store.checkNumber(BarKey.class, 2); + store.checkNumber(Bar.class, 1); + store.checkNumber(Foo.class, 1); + final Bar bar = store.getObject(Bar.class); + assertEquals(2, bar.getBarKeys().size()); + final Foo foo = store.getObject(Foo.class); + assertTrue(bar.getBarKeys().contains(foo.getBarKey())); + store.commitTransaction(); + } + + checkJoinColumnNames(store); + } + + private void checkJoinColumnNames(TestStore store) { + Connection conn = null; + Statement stmt = null; + try { + try { + conn = store.getConnection(); + stmt = conn.createStatement(); + // check version column name + ResultSet rs = stmt + .executeQuery("select barkeyentity_barkey_e_id from fooentity where barkeyentity_barkey_e_id > -1"); + assertTrue(rs.next()); + rs = stmt + .executeQuery("select barentity_barkeys_e_id from barkeyentity where barentity_barkeys_e_id > -1 and barentity_barkeys_idx > -1"); + assertTrue(rs.next()); + } finally { + if (stmt != null) + stmt.close(); + if (conn != null) + conn.close(); + } + } catch (SQLException e) { + throw new StoreTestException("Sql exception when checking db schema", e); + } + } +}
\ No newline at end of file |