EMF on existing database [message #878951] |
Wed, 30 May 2012 09:04 |
Chris Missing name 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 |
Martin Taal Messages: 5468 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 #880090 is a reply to message #880036] |
Fri, 01 June 2012 11:58 |
Martin Taal Messages: 5468 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03096 seconds