Problem
Given a technology specific Java Model T, I want to have:
- a technology agnostic model A to use in my code (i.e. the M in MVC).
- a persistence mechanism P to store my model A.
Approach
Currently I have figured out some options:
Option 1:
- Manually create the classes for A
- Manually create the code to translate T to A
- Manually create an XSD of a third JAXB-Model J
- Generate JAXB-Model-Classes from J
- Manually create the code to translate A to J
- Use JAXB to automatically save J
- When loading all translations have to be created into the other direction manually.
- Advantage: can't see one. Thats my question :)
- Disadvantage: most developing effort of all Options.
Option 2:
- Manually create an XSD of a JAXB-Model of A
- Generate JAXB-Model-Classes for A
- Manually create the code to translate T to A
- Use JAXB to automatically save A
- When loading the translations has to be created into the other direction manually.
- Advantage: Low developing effort. A can be persisted directly.
- Disadvantage: I read, that it's a bad Idea, to use JAXB-classes as modell. But I don't understand why.
Option 3:
- Manually create the Model of A as an eCore-Model
- Generate the classes of A from the ecore-Model
- Manually create the code to translate T to A
- Use eCore-resources to automatically save A
- When loading the translations has to be created into the other direction manually.
- Advantage: Low developing effort. A can be persisted directly.
- Disadvantage: None?
Looking at the advantages and disadvatages, I it seems like I should definitly use eCore instead of JAXB.
Question
- Is it really that clear, to use eCore? Or are there advantages/disadvantages I should also think about?
- Is here an easier way to translate from the technology specific model T to the technology agnostic modell A. Currenly I have to implement A and the translation A <-> T myself. Some easier way would be nice.