openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lew Bloch <lbl...@us.ibm.com>
Subject RE: Open JPA generates incorrect Union All for Date and Boolean Datatype
Date Fri, 11 Dec 2009 19:01:49 GMT


----- Quoting Message from Himadri  -----
> All Entities extends EntityBase which has common attribute like id and
> version. Do you think this is not a good way to implement ?

This could be a terrible, ghastly way to implement entities.  It forces
every table to have the same kind of "id" column.  I assume you defined
"id" as a long (or int or corresponding wrapper class) mapping to an
autogenerated sequence surrogate key.  Leaving aside the debate whether
such a surrogate key is ever a good idea, there certainly are cases where
it's a horridly bad idea.  Such cases include many-to-many linking tables
and subordinate tables with a foreign key reference back to their parent
table.

Unless I'm mapping to tables that inherit from other tables, I prefer not
to have entities inherit from parent entity classes.  There just isn't
enough of an "is-a" relationship in the application object model to justify
the practice.

Entity classes are supposed to form an object model, not a data model.
Creating inheritance hierarchies to reflect a purported database design is
backwards thinking.  It can even lead to a change in the data model to
match the mapping model, an egregious mistake.  I've seen this, where the
data-interaction classes assumed a 'Long' id key field and the middleware
team forced the data modelers to add such a column where the db design
didn't call for it.

I recommend to keep entity classes POJO, to abandon falsely-economical
inheritance notions, and to design objects to support the object model, not
the data model.

--
Lew Bloch

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message