diff options
author | Martin Taal | 2012-05-14 05:35:44 +0000 |
---|---|---|
committer | Martin Taal | 2012-05-14 05:35:44 +0000 |
commit | e345619b761144b4b300d71ced7bb198f8066ab2 (patch) | |
tree | f80323a48206d0696e83f8ff8fcc38f4397b768b /tests/org.eclipse.emf.teneo.hibernate.test | |
parent | a466709a72bd977f252e5632184685240efc68f9 (diff) | |
download | org.eclipse.emf.teneo-e345619b761144b4b300d71ced7bb198f8066ab2.tar.gz org.eclipse.emf.teneo-e345619b761144b4b300d71ced7bb198f8066ab2.tar.xz org.eclipse.emf.teneo-e345619b761144b4b300d71ced7bb198f8066ab2.zip |
Added jpa2 associationoverride.jointable support
Diffstat (limited to 'tests/org.eclipse.emf.teneo.hibernate.test')
8 files changed, 459 insertions, 16 deletions
diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/AssociationOverrideAction_hsqldb_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/AssociationOverrideAction_hsqldb_e_o_hibernate.hbm.xml new file mode 100644 index 000000000..4dc6c1c76 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/AssociationOverrideAction_hsqldb_e_o_hibernate.hbm.xml @@ -0,0 +1,68 @@ +<?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.emf.jpa2.associationoverride.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" table="`ADDRESS`"> + <meta attribute="eclassName" inherit="false">Address</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id type="long" name="myid" column="myid" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> + <meta attribute="syntheticId" inherit="false">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" inherit="false">true</meta> + </version> + <property name="street" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`STREET`"/> + </property> + <property name="postalCode" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`POSTALCODE`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.EmployeeImpl" entity-name="Employee" abstract="false" lazy="false" table="`EMPLOYEE`"> + <meta attribute="eclassName" inherit="false">Employee</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion" inherit="false">true</meta> + </version> + <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> + <list name="address" table="`ABC`" lazy="true" cascade="all,delete-orphan"> + <key update="true"> + <column name="`EMPLOYEE_ADDR_ID`" unique="false"/> + </key> + <list-index column="`PERSON_ADDRESS_IDX`"/> + <many-to-many entity-name="Address" unique="true" foreign-key="EMPLOYEE_ADDRESS"/> + </list> + <property name="department" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`DEPARTMENT`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.StudentImpl" entity-name="Student" abstract="false" lazy="false" table="`STUDENT`"> + <meta attribute="eclassName" inherit="false">Student</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion" inherit="false">true</meta> + </version> + <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> + <list name="address" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="STUDENT_ADDRESS"> + <column name="`STUDENT_ADDRESS_ID`" unique="false"/> + </key> + <list-index column="`STUDENT_ADDRESS_IDX`"/> + <one-to-many entity-name="Address"/> + </list> + <property name="faculty" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`FACULTY`"/> + </property> + </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.jpa2/AssociationOverrideAction_hsqldb_h_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/AssociationOverrideAction_hsqldb_h_o_hibernate.hbm.xml new file mode 100644 index 000000000..78b413484 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/AssociationOverrideAction_hsqldb_h_o_hibernate.hbm.xml @@ -0,0 +1,77 @@ +<?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.emf.jpa2.associationoverride.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" discriminator-value="Address" table="`ADDRESS`"> + <meta attribute="eclassName" inherit="false">Address</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id type="long" name="myid" column="myid" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> + <meta attribute="syntheticId" inherit="false">true</meta> + <generator class="native"/> + </id> + <discriminator type="string"> + <column name="`DTYPE`" index="ADDRESSDTYPE" 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" inherit="false">true</meta> + </version> + <property name="street" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`STREET`"/> + </property> + <property name="postalCode" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`POSTALCODE`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.EmployeeImpl" entity-name="Employee" abstract="false" lazy="false" discriminator-value="Employee" table="`EMPLOYEE`"> + <meta attribute="eclassName" inherit="false">Employee</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <discriminator type="string"> + <column name="`DTYPE`" index="EMPLOYEEDTYPE" 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" inherit="false">true</meta> + </version> + <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> + <list name="address" table="`ABC`" lazy="true" cascade="all,delete-orphan"> + <key update="true"> + <column name="`EMPLOYEE_ADDR_ID`" unique="false"/> + </key> + <list-index column="`PERSON_ADDRESS_IDX`"/> + <many-to-many entity-name="Address" unique="true" foreign-key="EMPLOYEE_ADDRESS"/> + </list> + <property name="department" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`DEPARTMENT`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.StudentImpl" entity-name="Student" abstract="false" lazy="false" discriminator-value="Student" table="`STUDENT`"> + <meta attribute="eclassName" inherit="false">Student</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <discriminator type="string"> + <column name="`DTYPE`" index="STUDENTDTYPE" 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" inherit="false">true</meta> + </version> + <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> + <list name="address" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="STUDENT_ADDRESS"> + <column name="`STUDENT_ADDRESS_ID`" unique="false"/> + </key> + <list-index column="`STUDENT_ADDRESS_IDX`"/> + <one-to-many entity-name="Address"/> + </list> + <property name="faculty" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`FACULTY`"/> + </property> + </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.jpa2/JPA2AssociationOverrideAction_hsqldb_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/JPA2AssociationOverrideAction_hsqldb_e_o_hibernate.hbm.xml new file mode 100644 index 000000000..4dc6c1c76 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/JPA2AssociationOverrideAction_hsqldb_e_o_hibernate.hbm.xml @@ -0,0 +1,68 @@ +<?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.emf.jpa2.associationoverride.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" table="`ADDRESS`"> + <meta attribute="eclassName" inherit="false">Address</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id type="long" name="myid" column="myid" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> + <meta attribute="syntheticId" inherit="false">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" inherit="false">true</meta> + </version> + <property name="street" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`STREET`"/> + </property> + <property name="postalCode" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`POSTALCODE`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.EmployeeImpl" entity-name="Employee" abstract="false" lazy="false" table="`EMPLOYEE`"> + <meta attribute="eclassName" inherit="false">Employee</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion" inherit="false">true</meta> + </version> + <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> + <list name="address" table="`ABC`" lazy="true" cascade="all,delete-orphan"> + <key update="true"> + <column name="`EMPLOYEE_ADDR_ID`" unique="false"/> + </key> + <list-index column="`PERSON_ADDRESS_IDX`"/> + <many-to-many entity-name="Address" unique="true" foreign-key="EMPLOYEE_ADDRESS"/> + </list> + <property name="department" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`DEPARTMENT`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.StudentImpl" entity-name="Student" abstract="false" lazy="false" table="`STUDENT`"> + <meta attribute="eclassName" inherit="false">Student</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion" inherit="false">true</meta> + </version> + <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> + <list name="address" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="STUDENT_ADDRESS"> + <column name="`STUDENT_ADDRESS_ID`" unique="false"/> + </key> + <list-index column="`STUDENT_ADDRESS_IDX`"/> + <one-to-many entity-name="Address"/> + </list> + <property name="faculty" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`FACULTY`"/> + </property> + </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.jpa2/JPA2AssociationOverrideAction_hsqldb_h_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/JPA2AssociationOverrideAction_hsqldb_h_o_hibernate.hbm.xml new file mode 100644 index 000000000..78b413484 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.jpa2/JPA2AssociationOverrideAction_hsqldb_h_o_hibernate.hbm.xml @@ -0,0 +1,77 @@ +<?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.emf.jpa2.associationoverride.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" discriminator-value="Address" table="`ADDRESS`"> + <meta attribute="eclassName" inherit="false">Address</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id type="long" name="myid" column="myid" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler"> + <meta attribute="syntheticId" inherit="false">true</meta> + <generator class="native"/> + </id> + <discriminator type="string"> + <column name="`DTYPE`" index="ADDRESSDTYPE" 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" inherit="false">true</meta> + </version> + <property name="street" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`STREET`"/> + </property> + <property name="postalCode" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`POSTALCODE`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.EmployeeImpl" entity-name="Employee" abstract="false" lazy="false" discriminator-value="Employee" table="`EMPLOYEE`"> + <meta attribute="eclassName" inherit="false">Employee</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <discriminator type="string"> + <column name="`DTYPE`" index="EMPLOYEEDTYPE" 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" inherit="false">true</meta> + </version> + <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> + <list name="address" table="`ABC`" lazy="true" cascade="all,delete-orphan"> + <key update="true"> + <column name="`EMPLOYEE_ADDR_ID`" unique="false"/> + </key> + <list-index column="`PERSON_ADDRESS_IDX`"/> + <many-to-many entity-name="Address" unique="true" foreign-key="EMPLOYEE_ADDRESS"/> + </list> + <property name="department" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`DEPARTMENT`"/> + </property> + </class> + <class name="org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.impl.StudentImpl" entity-name="Student" abstract="false" lazy="false" discriminator-value="Student" table="`STUDENT`"> + <meta attribute="eclassName" inherit="false">Student</meta> + <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/emf/jpa2/associationoverride</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="false" name="`ID`"/> + </id> + <discriminator type="string"> + <column name="`DTYPE`" index="STUDENTDTYPE" 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" inherit="false">true</meta> + </version> + <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> + <list name="address" lazy="true" cascade="all,delete-orphan"> + <key update="true" foreign-key="STUDENT_ADDRESS"> + <column name="`STUDENT_ADDRESS_ID`" unique="false"/> + </key> + <list-index column="`STUDENT_ADDRESS_IDX`"/> + <one-to-many entity-name="Address"/> + </list> + <property name="faculty" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> + <column not-null="true" unique="false" name="`FACULTY`"/> + </property> + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_e_o_hibernate.hbm.xml index 3610c8df5..8bb7a5e10 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_e_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_e_o_hibernate.hbm.xml @@ -39,13 +39,8 @@ <subclass name="org.eclipse.emf.teneo.samples.issues.bz247939.impl.CatImpl" entity-name="Cat" abstract="false" lazy="false" extends="Animal" discriminator-value="Cat"> <meta attribute="eclassName" inherit="false">Cat</meta> <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/issues/bz247939</meta> - <join table="`CAT`"> - <key> - <column name="`ANIMAL_ID`"/> - </key> - <many-to-one name="owner" entity-name="Owner" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="CAT_OWNER" insert="true" update="true" not-null="false"> - <column not-null="false" unique="false" name="`CAT_OWNER_ID`"/> - </many-to-one> - </join> + <many-to-one name="owner" entity-name="Owner" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="CAT_OWNER" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`CAT_OWNER_ID`"/> + </many-to-one> </subclass> </hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_h_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_h_o_hibernate.hbm.xml index f7fc511f9..e484bd7b2 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_h_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.test.issues/BZ247939Action_hsqldb_h_o_hibernate.hbm.xml @@ -42,13 +42,8 @@ <subclass name="org.eclipse.emf.teneo.samples.issues.bz247939.impl.CatImpl" entity-name="Cat" abstract="false" lazy="false" extends="Animal" discriminator-value="Cat"> <meta attribute="eclassName" inherit="false">Cat</meta> <meta attribute="epackage" inherit="false">http://www.eclipse.org/emf/teneo/samples/issues/bz247939</meta> - <join table="`CAT`"> - <key> - <column name="`ANIMAL_ID`"/> - </key> - <many-to-one name="owner" entity-name="Owner" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="CAT_OWNER" insert="true" update="true" not-null="false"> - <column not-null="false" unique="false" name="`CAT_OWNER_ID`"/> - </many-to-one> - </join> + <many-to-one name="owner" entity-name="Owner" lazy="false" cascade="merge,persist,save-update,lock,refresh" foreign-key="CAT_OWNER" insert="true" update="true" not-null="false"> + <column not-null="false" unique="false" name="`CAT_OWNER_ID`"/> + </many-to-one> </subclass> </hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/AllTests.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/AllTests.java index 251d0dd3d..eaebe2f27 100755 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/AllTests.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/AllTests.java @@ -26,6 +26,7 @@ public class AllTests { TestSuite suite = new MultiCfgTestSuite( "Test for org.eclipse.emf.teneo.hibernate.test.emf.jpa2", HibernateTestbed.instance().getConfigurations()); + suite.addTestSuite(JPA2AssociationOverrideAction.class); suite.addTestSuite(ElementCollectionAction.class); suite.addTestSuite(OrderColumnAction.class); suite.addTestSuite(MapsIdAction.class); diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/JPA2AssociationOverrideAction.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/JPA2AssociationOverrideAction.java new file mode 100755 index 000000000..e997e7b18 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/jpa2/JPA2AssociationOverrideAction.java @@ -0,0 +1,162 @@ +/** + * <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: AssociationOverrideAction.java,v 1.11 2010/02/06 18:25:53 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.test.emf.jpa2; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; +import java.util.Properties; + +import org.eclipse.emf.teneo.PersistenceOptions; +import org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.Address; +import org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.AssociationoverrideFactory; +import org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.AssociationoverridePackage; +import org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.Employee; +import org.eclipse.emf.teneo.samples.emf.jpa2.associationoverride.Student; +import org.eclipse.emf.teneo.test.AbstractTestAction; +import org.eclipse.emf.teneo.test.stores.TestStore; + +/** + * Simple test for AssociationOverride. + */ +public class JPA2AssociationOverrideAction extends AbstractTestAction { + private static final String EMPLOYEE_DEPARTMENT = "R&D"; + + private static final String EMPLOYEE_NAME = "Piet Pietersen"; + + private static final String EMPLOYEE_VERIFICATION_QUERY = + "SELECT COUNT(*) FROM ABC A INNER JOIN EMPLOYEE E ON A.EMPLOYEE_ADDR_ID = E.ID".toLowerCase(); + + private static final AssociationoverrideFactory FACTORY = AssociationoverrideFactory.eINSTANCE; + + private static final Address DEFAULT_ADDRESS = FACTORY.createAddress(); + + private static final String STUDENT_FACULTY = "Biology"; + private static final String STUDENT_NAME = "Jan Janssen"; + + private static final String STUDENT_VERIFICATION_QUERY = + "SELECT COUNT(*) FROM STUDENT A INNER JOIN ADDRESS B ON A.ID = B.STUDENT_ADDRESS_ID".toLowerCase(); + + static { + DEFAULT_ADDRESS.setStreet("Amsterdamseweg 123"); + DEFAULT_ADDRESS.setPostalCode("1234 AZ"); + } + + public JPA2AssociationOverrideAction() { + super(AssociationoverridePackage.eINSTANCE); + } + + @Override + public void doAction(TestStore store) { + storeStudent(store); + storeEmployee(store); + testStudent(store); + testEmployee(store); + testTables(store); + } + + private Address getAddress() { + final Address address = FACTORY.createAddress(); + address.setStreet(DEFAULT_ADDRESS.getStreet()); + address.setPostalCode(DEFAULT_ADDRESS.getPostalCode()); + return address; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.emf.teneo.test.AbstractTestAction#getExtraConfigurationProperties() + */ + @Override + public Properties getExtraConfigurationProperties() { + final Properties props = new Properties(); + props.put(PersistenceOptions.ID_COLUMN_NAME, "myid"); + return props; + } + + private void storeEmployee(TestStore store) { + store.beginTransaction(); + final Employee employee = FACTORY.createEmployee(); + employee.setName(EMPLOYEE_NAME); + employee.setDepartment(EMPLOYEE_DEPARTMENT); + employee.getAddress().add(getAddress()); + store.store(employee); + store.commitTransaction(); + } + + private void storeStudent(TestStore store) { + store.beginTransaction(); + final Student student = FACTORY.createStudent(); + student.setName(STUDENT_NAME); + student.getAddress().add(getAddress()); + student.setFaculty(STUDENT_FACULTY); + store.store(student); + store.commitTransaction(); + } + + private void testAddress(Address address) { + assertEquals(DEFAULT_ADDRESS.getStreet(), address.getStreet()); + assertEquals(DEFAULT_ADDRESS.getPostalCode(), address.getPostalCode()); + } + + private void testEmployee(TestStore store) { + store.beginTransaction(); + final List<?> results = store.query("select e from Employee e"); + assertEquals(1, results.size()); + final Employee employee = (Employee) results.get(0); + assertEquals(EMPLOYEE_NAME, employee.getName()); + assertEquals(EMPLOYEE_DEPARTMENT, employee.getDepartment()); + testAddress(employee.getAddress().get(0)); + store.commitTransaction(); + } + + private void testStudent(TestStore store) { + store.beginTransaction(); + final List<?> results = store.query("select s from Student s"); + assertEquals(1, results.size()); + final Student student = (Student) results.get(0); + assertEquals(STUDENT_NAME, student.getName()); + assertEquals(STUDENT_FACULTY, student.getFaculty()); + testAddress(student.getAddress().get(0)); + store.commitTransaction(); + } + + private void testTables(TestStore store) { + final Connection conn = store.getConnection(); + Statement stmt = null; + ResultSet rs = null; + try { + stmt = conn.createStatement(); + rs = stmt.executeQuery(STUDENT_VERIFICATION_QUERY); + rs.next(); + assertEquals(1, rs.getInt(1)); + rs.close(); + rs = stmt.executeQuery(EMPLOYEE_VERIFICATION_QUERY); + rs.next(); + assertEquals(1, rs.getInt(1)); + } catch (final SQLException e) { + assertTrue(e.getMessage(), false); + } finally { + try { + if (stmt != null) { + stmt.close(); + } + } catch (final SQLException e) { + } + try { + if (rs != null) { + rs.close(); + } + } catch (final SQLException e) { + } + } + } +} |