Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF on existing database(Can i use EMF on an existing database)
EMF on existing database [message #878951] Wed, 30 May 2012 09:04 Go to next message
Chris Missing name is currently offline Chris Missing nameFriend
Messages: 3
Registered: December 2009
Location: Belgium
Junior Member
We would like to build an RCP/RAP application based on an existing database.
We would like to use EMF/Teneo (hibernate), as EMF model objects are easy to use for binding in an RCP/RAP application.
But it seems that using EMF on an existing DB is not possible, as id's of PK's should be unique over all tables, and this is not the case for our DB.
We generate our own id's for every table using db sequences , which is not supported for EMF/Teneo.
Also EMF/Teneo add's fields to our existing tables (eg DTYPE) , which is something we don't want.
Reverse engineering is also not supported in EMF.

So if all of the above is true, what are our other options ?
Does RCP support binding for plain pojo's (which in our case would be hibernate pojo's) ?
In that case we would leave EMF for what it is, and just write our own hibernate layer, and use the
hibernate objects in our RCP/RAP application.

grtz,
Chris.


Chris N

[Updated on: Fri, 01 June 2012 12:01]

Report message to a moderator

Re: EMF on existing database [message #878996 is a reply to message #878951] Wed, 30 May 2012 10:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Chris,
With Teneo id's don't need to be unique across all tables, they should be unique within a table. Only for EMF if you set
an eattribute to be an ID (a xml ID) then when creating an xml document EMF will complain that there are id collisions,
but this only occurs in case you set an eattribute to be an ID.
Teneo adds fields like DTYPE if you use single table inheritance mapping, but normally this is not needed for a joined
inheritance mapping strategy.

Then disable/prevent some other columns by setting these options:
PersistenceOptions.ALWAYS_VERSION to false
PersistenceOptions.DISABLE_ECONTAINER_MAPPING to true

I remember that I already mentioned this, still (with the danger I am repeating myself :-), another option you can use
is to use Texo which is a more compliant JPA/ORM solution and maybe easier to map (http://wiki.eclipse.org/Texo). It
generates real pojo's from an ecore model.

I think that databinding also works for pojo's (not sure). But I would advice to spend a separate post on this topic. I
know that there are people on the forum who can give a summary of the pro-cons using EMF versus pojos for databinding.

gr. Martin

On 05/30/2012 11:04 AM, iadv Mising name wrote:
>
> We would like to build an RCP/RAP application based on an existing database.
> We would like to use EMF/Teneo (hibernate), as EMF model objects are easy to use for binding in an RCP/RAP application.
> But it seems that using EMF on an existing DB is not possible, as id's of PK's should be unique over all tables, and
> this is not the case for our DB.
> We generate our own id's for every table using db sequences , which is not supported for EMF/Teneo.
> Also EMF/Teneo add's fields to our existing tables (eg DTYPE) , which is something we don't want.
> Reverse engineering is also not supported in EMF.
>
> So if all of the above is true, what are our other options ?
> Does RCP support binding for plain pojo's (which in our case would be hibernate pojo's) ?
> In that case we would leave EMF for what it is, and just write our own hibernate layer, and use the
> hibernate objects in our RCP/RAP application.
>
> grtz,
> Chris.


--

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: EMF on existing database [message #879599 is a reply to message #878996] Thu, 31 May 2012 13:48 Go to previous messageGo to next message
Chris Missing name is currently offline Chris Missing nameFriend
Messages: 3
Registered: December 2009
Location: Belgium
Junior Member
Hello Martin,

Tnx for the reply, we'll have a look at Texo

grtz,
Chris.


Chris N
Re: EMF on existing database [message #880036 is a reply to message #878996] Fri, 01 June 2012 10:13 Go to previous messageGo to next message
Tom Bauwens is currently offline Tom BauwensFriend
Messages: 10
Registered: May 2012
Junior Member
Hi Martin,

Thanks for the explanation.

I have got it working without the EMF/Teneo specific columns.

Solution is:
1. Keep the ID attribute to true in the EMF model otherwise EMF/Teneo will add an e_id column
2. Set the persistente options like you said:
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");

Regards,
Tom
Re: EMF on existing database [message #880090 is a reply to message #880036] Fri, 01 June 2012 11:58 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Tom,
Instead of using the ID attribute you can also annotate the id eattributes with the @Id annotation, that will give the
same result without the XML-ID disadvantage.

gr. Martin

On 06/01/2012 12:13 PM, Tom Bauwens wrote:
> Hi Martin,
>
> Thanks for the explanation.
>
> I have got it working without the EMF/Teneo specific columns.
>
> Solution is:
> 1. Keep the ID attribute to true in the EMF model otherwise EMF/Teneo will add an e_id column
> 2. Set the persistente options like you said:
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
>
> Regards,
> Tom


--

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: EMF on existing database [message #880119 is a reply to message #880090] Fri, 01 June 2012 13:09 Go to previous message
Tom Bauwens is currently offline Tom BauwensFriend
Messages: 10
Registered: May 2012
Junior Member
Hi Martin,

A follow-up question if you don't mind.
How do I deal with existing foreign keys? I have for example a table address with a foreign key to person. The column is called pers_id. EMF/Teneo always generates an extra column which is the combination of the referencing ETYPE (in this case Person) and the name of the reference (in this case pers) and id column name. So, the extra column is named: Person_pers_id. How can I now make EMF/Teneo used the existing column pers_id instead of the generated Person_pers_id?

Thanks!

Tom
Previous Topic:[CDO] Server/Clone Architecture advise needed
Next Topic:[CDO/Dawn] Different object was registered for OID
Goto Forum:
  


Current Time: Mon Nov 24 06:31:47 GMT 2014

Powered by FUDForum. Page generated in 0.11362 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software