I want to create a data model for my new application but I don't want to bind my application directly to any ORM framework such as Jpa. I don't want any Jpa-things in my underlying model. I want to "append" them.
So my first approach for the model looks like this:
And if I want to use this with Jpa now, this would be nice:
But I get some problems using this solution. For example I get the following exception:
I know, I can make some workarounds by creating a new instance of JpaFoo and setting all its values to the values of super.getFoo(). But I want to know if this is the common way for this problem or if I am completely wrong with my ideas.
I think you should not inherit your JPA classes from your base classes, but create an interface and implement this interface in both classes. And you should write your code against the interfaces, not the classes.
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!