当前位置:首页 > 数据库 > 正文

[email protected]

2020-02-12 数据库

 

  今天阅读前辈的代码时,发现一个新的注解 @MappedSuperclass ,下面就来了解下它是干什么的:

  首先官方文档给出的解释是:

  Designates a class whose mapping information is applied to the entities that inherit from it. A mapped superclass has no separate table defined for it.

  简单讲就是,指定一个类,将它的映射信息应用于继承它的实体。而不把它定义成一个单独的表。

总结:

  • 使用在父类中
  • @MappedSuperclass 描述的类中不能同时使用@Entity和@Table
  • @MappedSuperclass 描述的类中不会映射到数据库表中,但是可以被继承它的类映射到数据库表中

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/SQL/14844.html