Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Support for not-found or custom data types
[Teneo] Support for not-found or custom data types [message #1733319] Thu, 26 May 2016 06:11 Go to next message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Dear all,

I want to use Teneo for extracting an EMF model from a legacy database. So far, things are going well but I encountered a problem caused by the legacy representation of non-existing foreign keys: The legacy application does not use NULL to represent missing references but uses 0. This leads to problems when using the join-column directive in the XML mapping of Teneo because it considers 0 as valid foreign key and tries to resolve this reference. This does, obviously, not work. I cannot change all zeros to NULL because the legacy application would override it.

I looked for a solution and found three approaches:
  • Create two classes in the EMF model that inherit from the same base class. One contains a reference to the element and the other class a property with a fixed value of 0. I use SINGLE_TABLE inheritance and a discriminator-formula that uses the foreign key field to determine the correct EMF model element. This is, obviously, only sufficient if there is only a small amount of such foreign keys.
  • Use the Hibernate not-found annotation to tell the mapping framework to ignore the missing reference. This, however, does not write back 0 to the database but NULL.
  • Use a custom data type to convert the value before trying to resolve the foreign key.
The first approach works when using Teneo. I could, however, not manage to make the latter two approaches work. Is there any support for them in Teneo? Is there another better approach for using Teneo in my scenario?

Best regards
Stephan
Re: [Teneo] Support for not-found or custom data types [message #1733429 is a reply to message #1733319] Fri, 27 May 2016 11:48 Go to previous messageGo to next message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Dear all,

I found that it is pretty easy to realize the third approach with the custom data type:

You have to create a class that implements the org.hibernate.usertype.UserType interface. You do the conversion in nullSafeGet and nullSafeSet. For the scenario that class A refers to class B, you define the id of class B to be of this created new type. The tricky part for me was to determine which property should be typed with the new user type.

Best regards
Stephan
Re: [Teneo] Support for not-found or custom data types [message #1734005 is a reply to message #1733429] Thu, 02 June 2016 21:50 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Stephan,
Nice, for eattributes you can also define an EDatatype and annotate the EDatatype with a custom datatype annotation.

gr. Martin
Previous Topic:[teneo] Hibernate 5 support
Next Topic:[EMF Forms] Master Detail View invisible/does not show up
Goto Forum:
  


Current Time: Thu Apr 18 09:23:11 GMT 2024

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

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

Back to the top