Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

data model for any orm framework

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
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:

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.

He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic