aspose file tools
The moose likes Object Relational Mapping and the fly likes [EJB3] Table per Concrete Class Strategy Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "[EJB3] Table per Concrete Class Strategy" Watch "[EJB3] Table per Concrete Class Strategy" New topic
Author

[EJB3] Table per Concrete Class Strategy

Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

What is the motivation behind the "Table per Concrete Class Strategy" @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) ?
It's not recommended, poor design, and optiional for persistence providers. Wouldn't it better not to put it in the spec ?


[SCBCD Wall of Fame] [My Blog]
All roads lead to JavaRanch
Help Japan. Make a donation.
Oliver Kamps
Greenhorn

Joined: May 15, 2007
Posts: 18
Hi,

this mapping can be very useful when you have to work with an existing database schema.

Whether or not this mapping is poor design depends on the situation at hand and is generally in the eye of the beholder. If you have a number of concrete classes in a hierarchy with a large number of objects per class (read: a large number of rows in each table) *and* you only rarely need polymorphic access in your queries, then this mapping might actually be pretty good design.

Cheers,
Oliver
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

Moving this to the more appropriate Object Relational Mapping ORM forum. All JPA questions go there.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

Nice response Oliver.

Yes, what happens if you have a legacy databse, you can't change the databse design, and this is how it is laid out. No choice, but have to use this mapping.

Mark
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

Thanks both of you, I've got it
In the spec, they could have made it mandatory for persistence providers then. I can't understand why they have decided to make it optional.
 
jQuery in Action, 2nd edition
 
subject: [EJB3] Table per Concrete Class Strategy
 
Threads others viewed
JPA Discriminator
Showing Entity in class diagram
Best inheritance mapping strategy..
Primary Key Autogeneration for InheritenceType. TABLE_PER_CLASS
Single table for Class or Single Table for Classes
MyEclipse, The Clear Choice