Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 07:29 Go to next message
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 207
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=&quot;order&quot;, 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=&quot;ORDER_ID&quot;, nullable=&quot;false&quot;)"/>
      </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=&quot;PERSON_ID&quot;, nullable=&quot;false&quot;)"/>
      </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 07: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 11:44 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5300
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 #1021328 is a reply to message #1021168] Tue, 19 March 2013 17:54 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 207
Registered: February 2012
Location: Düsseldorf
Senior Member
Thank you Martin for your attention. If you can put some light into this I would really be thankful. Meanwhile it is more of an academic question because I have simply modified my schema. But still it is something between me and Teneo. I have spend a lot of time in this and other related mapping problems and somehow I am at a point of no return Smile. It's probably just some very simple configuration issue.

I really appreciate your work and your committment!

Regards,
Thorsten
Re: [teneo] Problem with double index on column [message #1021342 is a reply to message #1021328] Tue, 19 March 2013 18:34 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5300
Registered: July 2009
Senior Member
Hi Thorsten,
Okay np, feel free to ask any other question. Also make sure to check out the global options which can be used to
control mapping behavior:
http://wiki.eclipse.org/Teneo/Hibernate/Configuration_Options

gr. Martin

On 03/19/2013 10:54 PM, Thorsten Schlathölter wrote:
> Thank you Martin for your attention. If you can put some light into this I would really be thankful. Meanwhile it is
> more of an academic question because I have simply modified my schema. But still it is something between me and Teneo. I
> have spend a lot of time in this and other related mapping problems and somehow I am at a point of no return :). It's
> probably just some very simple configuration issue.
>
> I really appreciate your work and your committment!
>
> 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 #1021684 is a reply to message #1021342] Wed, 20 March 2013 10:06 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 207
Registered: February 2012
Location: Düsseldorf
Senior Member
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
Re: [teneo] Problem with double index on column [message #1021705 is a reply to message #1021684] Wed, 20 March 2013 10:42 Go to previous message
Martin Taal is currently offline Martin Taal
Messages: 5300
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
Previous Topic:[Teneo]dynamic table-name depending on attribute
Next Topic:[Texo] Retrieve children
Goto Forum:
  


Current Time: Thu Apr 17 03:54:51 EDT 2014

Powered by FUDForum. Page generated in 0.01938 seconds