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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

data model for any orm framework

 
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
 
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
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic