Annotation Type PrimaryKey


@Target(FIELD) @Retention(RUNTIME) @Documented public @interface PrimaryKey
此注解用于标记字段是数据库中的主键。

应用于数据库实体类的字段时,框架或工具可能通过该注解识别主键字段,并在 数据库操作(例如插入、更新或删除)中给予特殊处理。

注解目标:

  • 仅限字段级别使用。

保留策略:

  • 运行时可用(@RetentionPolicy.RUNTIME),可通过反射机制在运行时获取注解信息。

使用示例:

 public class User {
     @PrimaryKey
     private Long id;
 }
 
Since:
1.0
Author:
Siwen Yu (yusiwen@gmail.com)