JPA通用策略生成器(@GeneratedValue 四种标准用法为TABLE, SEQUENCE, IDENTITY, AUTO)

简介: JPA通用策略生成器(@GeneratedValue 四种标准用法为TABLE, SEQUENCE, IDENTITY, AUTO)

JPA通用策略生成器

查看JPA的源码可知:

packagejavax.persistence;
/** * Defines the types of primary key generation strategies. ** @see GeneratedValue** @since Java Persistence 1.0*/publicenumGenerationType { 
/*** Indicates that the persistence provider must assign * primary keys for the entity using an underlying * database table to ensure uniqueness.*/TABLE, 
/*** Indicates that the persistence provider must assign * primary keys for the entity using a database sequence.*/SEQUENCE, 
/*** Indicates that the persistence provider must assign * primary keys for the entity using a database identity column.*/IDENTITY, 
/*** Indicates that the persistence provider should pick an * appropriate strategy for the particular database. The * <code>AUTO</code> generation strategy may expect a database * resource to exist, or it may attempt to create one. A vendor * may provide documentation on how to create such resources * in the event that it does not support schema generation * or cannot create the schema resource at runtime.*/AUTO}

JPA提供的四种标准用法为TABLE, SEQUENCE, IDENTITY, AUTO

TABLE:使用一个特定的数据库表格来保存主键。  

SEQUENCE:根据底层数据库的序列来生成主键,条件是数据库支持序列。  

IDENTITY:主键由数据库自动生成(主要是自动增长型) 。

AUTO:主键由程序控制。  

 

详情请查看另外一篇,感觉写的很全,如有兴趣的话,可以看看:https://blog.csdn.net/tree_java/article/details/71158122


本文首发于CSDN,为博主原创文章,如果需要转载,请注明出处,谢谢!


完结!

目录
打赏
0
0
0
0
17
分享
相关文章
Java-----银行管理系统
Java-----银行管理系统
177 0
VUE之vxe-table高级表格(表格内增删改、导入、导出、自定义打印、列设置隐藏显示等)用法
VUE之vxe-table高级表格(表格内增删改、导入、导出、自定义打印、列设置隐藏显示等)用法
8317 0
VUE之vxe-table高级表格(表格内增删改、导入、导出、自定义打印、列设置隐藏显示等)用法
开发指南—Sequence—隐式用法—查看表信息及相关Sequence类型
本文主要介绍如何对使用Sequence类型作为自增列的表信息以及相关Sequence类型进行查看。
116 0
开发指南—Sequence—隐式用法—CREATE TABLE
在为拆分表或广播表的主键定义AUTO_INCREMENT后,Sequence可以用于自动填充主键,由PolarDB-X自动维护。 扩展标准建表语法,增加了自增列的Sequence类型,如果未指定类型关键字,则默认类型为GROUP。PolarDB-X自动创建的、跟表相关联的Sequence名称,都是以AUTO_SEQ_为前缀,后面加上表名。
开发指南—DAL语句—SET—SET语句变量设置
您可以通过SET语句设置各类变量,包括用户自定义的变量、session变量和global变量。
127 0
10分钟学会使用YOLO及Opencv实现目标检测(下)|附源码
本文介绍使用opencv和yolo完成视频流目标检测,代码解释详细,附源码,上手快。
9181 1
【第 1 9 个代码模型】Set 集合接口(Set 接口常用子类)|学习笔记
快速学习 【第 19 个代码模型】Set 集合接口(Set 接口常用子类)
107 0
【第 1 9 个代码模型】Set 集合接口(Set 接口常用子类)|学习笔记
Springboot----实现邮箱验证码登录(代码部分)
Springboot----实现邮箱验证码登录(代码部分)
1201 0
Springboot----实现邮箱验证码登录(代码部分)
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等