开发者

Documents-oriented architecture and hibernate. Starting point

开发者 https://www.devze.com 2023-03-31 11:46 出处:网络
I want to create architecture like this (abstract scheme): abstract class Document - number - autor - createDate

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消