This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16599|Reply: 0

[Source] @MappedSuperclass the use of annotations

[Copy link]
Posted on 4/8/2019 4:28:38 PM | | |
When I was developing, I read other people's code, and I found a note called @MappedSuperclass, based on the reason why I saw it for the first time, I looked up its meaning on the Internet, and I will summarize it here.


Conditions of use:

When we are working on a development project, we often use the operation of entity mapping to a database table, and at this time we often find that in several entity classes that we need to implicit,There are several common attributes such as number ID, created by, created time, modified, modified time, notes, etc。 In this case, we might think of abstracting these properties as a parent class, and then inheriting the parent class with a different entity class.

Then we canUsing @MappedSuperclass annotation, we can treat the entity class as the base class entity, which is not implicit to the database table, but the subclass entity that inherits it will automatically scan the implicit attributes of the base class entity and add it to the corresponding database table of the subclass entity.


Usage environment:

1.@MappedSuperclass annotations are used on top of the parent class to identify the parent class

A class identified 2.@MappedSuperclass indicates that it cannot be mapped to a database table because it is not a complete entity class, but it has properties that can be implicit in the database table used by its subclass

3.@MappedSuperclass can no longer have @Entity or @Table annotations





Previous:MySQL parameter max_connect_errors analyze and clarify doubts
Next:Huawei Cisco Switch Learning
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com