users@glassfish.java.net

Re: Two entity classes mapped to same table

From: <glassfish_at_javadesktop.org>
Date: Fri, 18 May 2007 14:03:11 PDT

There is no inheritance relationship between these two entities, so therefore there is no discriminator column. This is legacy data that is not modelled accordingly.

The two classes both have the primary key and a set of fields that are unique to each class, and a common field that is used as a version field by the database.

The version field is updated automatically by the database when updates occur, so we don't actually change it at all (the container, peristence provider, or the app)

If I were to consider using a "monolithic" entity for the entire table, I don't think I would be hurt by performance, would I? I.E. there is no real benefit to me using multiple entity classes that map to the same table, other than to look more object oriented, right? (assuming we have no inheritance hierarchy)

The reason why I would consider the monolithic entity is because we may end up with situations where a transaction context has multiple updates to distinct entity classes that map to the same row, but don't make sense to have in an inheritance relationship.

Andrew
[Message sent by forum member 'asmithgf' (asmithgf)]

http://forums.java.net/jive/thread.jspa?messageID=217914