Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data model for any orm framework

 
Ethan Leroy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks in advance
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Sounds to me as if you want to create something similar to the DAO pattern from J2EE.

Maybe you should have a look at this:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html



If you prefer a simple hint:

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.

John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic