Hibernate自动值生成策略之间的区别? [英] Difference between Hibernate Automatic value generation strategies?

查看:110
本文介绍了Hibernate自动值生成策略之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两种自动价值生成策略有什么区别?

What is the difference between these two Automatic value generation strategies?

 1. @GeneratedValue
 2. @GeneratedValue(strategy=IDENTITY)

推荐答案

这类似于以下内容:

AUTO 表示持久性提供程序应为特定数据库选择适当的策略.

AUTO Indicates that the persistence provider should pick an appropriate strategy for the particular database.

身份 指示持久性提供程序必须使用数据库标识列为实体分配主键.

IDENTITY Indicates that the persistence provider must assign primary keys for the entity using database identity column.

序列 指示持久性提供程序必须使用数据库序列列为实体分配主键.

SEQUENCE Indicates that the persistence provider must assign primary keys for the entity using database sequence column.

表示持久性提供程序必须使用基础数据库表为实体分配主键,以确保唯一性.

TABLE Indicates that the persistence provider must assign primary keys for the entity using an underlying database table to ensure uniqueness.

在此处参考API http://docs.oracle .com/javaee/5/api/javax/persistence/GenerationType.html

这篇关于Hibernate自动值生成策略之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆