Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [teneo] Problem with double index on column
[teneo] Problem with double index on column [message #1021019] |
Tue, 19 March 2013 11:29 |
Thorsten Schlathölter Messages: 312 Registered: February 2012 Location: Düsseldorf |
Senior Member |
|
|
Hi,
I have a probably simple problem for which I cannot find a solution. I have the following mapping situation.
I have two main entities ORDER and PERSON. An ORDER can have PERSONs of different types assoicated (e.g. type "OWNER","RESPONSIBLE","RECEIVER"). I try so solve this by adding an entity ORDER_PERSON.
My current ecore model is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="sample"
nsURI="http://com.somesample" nsPrefix="sample">
<eClassifiers xsi:type="ecore:EClass" name="Order">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"
iD="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="orderPersons" ordered="false"
lowerBound="0" upperBound="-1" eType="#//OrderPerson" containment="true" eOpposite="#//OrderPerson/order">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@OneToMany(mappedBy="order", indexed=false)"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Person">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"
iD="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="OrderPerson">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"
iD="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="order" ordered="false"
unique="false" lowerBound="1" eType="#//Order" eOpposite="#//Order/orderPersons">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@JoinColumn(name="ORDER_ID", nullable="false")"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="person" ordered="false"
unique="false" lowerBound="1" eType="#//Person">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@JoinColumn(name="PERSON_ID", nullable="false")"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
The generated schema is as follows:
create table T_ORDER (
ID number(19,0) not null,
DTYPE varchar2(255 char) not null,
primary key (ID)
)
create table T_ORDER_PERSON (
ID number(19,0) not null,
DTYPE varchar2(255 char) not null,
ORDER_ID number(19,0), -- see question below
PERSON_ID number(19,0) not null,
TYPE varchar2(255 char),
primary key (ID)
)
create table T_PERSON (
ID number(19,0) not null,
DTYPE varchar2(255 char) not null,
NAME varchar2(255 char),
primary key (ID)
)
create index T_OrderDTYPE on T_ORDER (DTYPE)
alter table T_ORDER_PERSON
add constraint FK_OrderPerson_person
foreign key (PERSON_ID)
references T_PERSON
alter table T_ORDER_PERSON
add constraint FK_OrderPerson_order
foreign key (ORDER_ID)
references T_ORDER
create index T_OrderPersonDTYPE on T_ORDER_PERSON (DTYPE)
create index OrderPerson_person on T_ORDER_PERSON (PERSON_ID)
create index Order_orderPersons on T_ORDER_PERSON (ORDER_ID) -- see question below
create index OrderPerson_order on T_ORDER_PERSON (ORDER_ID) -- see question below
create index T_PersonDTYPE on T_PERSON (DTYPE)
create sequence hibernate_sequence
I have two issues:
1. How to get T_ORDER_PERSON.ORDER_ID not nullable?
2. How do I get rid of the second index (OrderPerson_order) on T_ORDER_PERSON.ORDER_ID?
Any help would be appreciated.
Regards,
Thorsten
[Updated on: Tue, 19 March 2013 11:30] Report message to a moderator
|
|
|
Re: [teneo] Problem with double index on column [message #1021168 is a reply to message #1021019] |
Tue, 19 March 2013 15:44 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thorsten,
I will need to try it myself in a testcase (using your model) to do some debugging. If you haven't gotten a reply in a
few days from me then feel free to ping on the forum again (in a friendly way :-).
gr. Martin
On 03/19/2013 12:29 PM, Thorsten Schlathölter wrote:
> Hi,
> I have a probably simple problem for which I cannot find a solution. I have the following mapping situation.
> I have two main entities ORDER and PERSON. An ORDER can have PERSONs of different types assoicated (e.g. type
> "OWNER","RESPONSIBLE","RECEIVER"). I try so solve this by adding an entity ORDER_PERSON.
>
> My current ecore model is as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="sample"
> nsURI="http://com.somesample" nsPrefix="sample">
> <eClassifiers xsi:type="ecore:EClass" name="Order">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELong"
> iD="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="orderPersons" ordered="false"
> lowerBound="0" upperBound="-1" eType="#//OrderPerson" containment="true" eOpposite="#//OrderPerson/order">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@OneToMany(mappedBy="order", indexed=false)"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Person">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELong"
> iD="true"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="OrderPerson">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELong"
> iD="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="order" ordered="false"
> unique="false" lowerBound="1" eType="#//Order" eOpposite="#//Order/orderPersons">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@JoinColumn(name="ORDER_ID", nullable="false")"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="person" ordered="false"
> unique="false" lowerBound="1" eType="#//Person">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@JoinColumn(name="PERSON_ID", nullable="false")"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
>
> The generated schema is as follows:
>
>
> create table T_ORDER (
> ID number(19,0) not null,
> DTYPE varchar2(255 char) not null,
> primary key (ID)
> )
>
> create table T_ORDER_PERSON (
> ID number(19,0) not null,
> DTYPE varchar2(255 char) not null,
> ORDER_ID number(19,0), -- see question below
> PERSON_ID number(19,0) not null,
> TYPE varchar2(255 char),
> primary key (ID)
> )
>
> create table T_PERSON (
> ID number(19,0) not null,
> DTYPE varchar2(255 char) not null,
> NAME varchar2(255 char),
> primary key (ID)
> )
>
> create index T_OrderDTYPE on T_ORDER (DTYPE)
>
> alter table T_ORDER_PERSON add constraint FK_OrderPerson_person foreign key (PERSON_ID)
> references T_PERSON
>
> alter table T_ORDER_PERSON add constraint FK_OrderPerson_order foreign key (ORDER_ID)
> references T_ORDER
>
> create index T_OrderPersonDTYPE on T_ORDER_PERSON (DTYPE)
>
> create index OrderPerson_person on T_ORDER_PERSON (PERSON_ID)
>
> create index Order_orderPersons on T_ORDER_PERSON (ORDER_ID)
>
> create index OrderPerson_order on T_ORDER_PERSON (ORDER_ID) -- see question below
>
> create index T_PersonDTYPE on T_PERSON (DTYPE)
>
> create sequence hibernate_sequence
>
>
> I have two issues:
> 1. How to get T_ORDER_PERSON.ORDER_ID not nullable?
> 2. How do I get rid of the second index on T_ORDER_PERSON.ORDER_ID?
>
> Any help would be appreciated.
>
> Regards,
> Thorsten
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
| | | |
Re: [teneo] Problem with double index on column [message #1021705 is a reply to message #1021684] |
Wed, 20 March 2013 14:42 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Here are some tips:
- web service/web server environment --> texo/jpa
- RCP 2 tier (so rcp directly talking to the db): Teneo
- RCP 3 tier (so rcp <--> server <--> db): Texo/JPA using the TexoJSONResource
I like Texo very much because it is cleaner, Teneo works on the internals of Hibernate to make EMF work nicely with
Hibernate. Texo works with Hibernate in a standard way, that's why you can also use EclipseLink with Texo. In addition
Texo has all this other stuff related to json serialization, full web service crud support, test data generation, etc.
So if you have a choice I would use Texo...
The only missing feature in Texo is dynamic models, so models which change at runtime and need to deployed without
restarting the application, Teneo is capable of this, Texo is not.
gr. Martin
On 03/20/2013 03:06 PM, Thorsten Schlathölter wrote:
> One thing that bothers me is the question if it was a good idea to choose Teneo for combining EMF/Hibernate or if I
> should have better chosen Texo/JPA? Is there a simple answer for that?
>
> Regards,
> Thorsten
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Fri Apr 26 03:32:57 GMT 2024
Powered by FUDForum. Page generated in 0.03645 seconds
|