|[Teneo] Support for not-found or custom data types [message #1733319]
||Thu, 26 May 2016 06:11
| Stephan Seifermann
Registered: March 2015
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:
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?
- 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.
Powered by FUDForum
. Page generated in 0.01333 seconds