I want to create architecture like this (abstract scheme):
abstract class Document
- number
- autor
- createDate
class Order extends Document
- cost
- client
class Discount extends Document
- value
...
Should Docume开发者_开发问答nt class have annotation @MappedSuperclass (no table for Documents), or it should have it's own table - One-to-One relation with concrete entities?
Is there some ready templates for documents-oriented system on java+hibernate, or some good examples?
Does your application deal with documents, or does it deal with orders and discounts. For example, do you have some page used to search and display documents, regardless of their type? Or do you have some other entity which has an association (ToOne or ToMany) with a document (and not with an order or with a discount)?
If the answer to one of these questions is yes, then Document
should be an Entity
(which doesn't mean it should have its own table: Hibernate supports three types of inheritance mapping for entities).
If, in fact, Discount
and Order
are two unrelated entities which just have a common set of attributes (number, author and creation date), the Document should just be a MappedSuperclass
.
精彩评论