本文介绍了休眠中的 GenerationType.AUTO 与 GenerationType.IDENTITY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们使用 MySQL 作为数据库,我们使用

Currently, we are using MySQL as a database and we use

@Generated Value(strategy = GenerationType.IDENTITY)

它在某些情况下运行良好,我们需要将数据库迁移到 Oracle 时它无法正常运行.如果有人知道这背后的实际区别是什么以及它是如何工作的?

It's working perfectly in certain situations we need to migrate our database to Oracle at that time it's not working properly. If anyone knows what's the actual difference is present behind this and how it's working?

推荐答案

它如何与 Oracle 一起正常工作"(您没有像您所说的那样定义基本信息)?我没有看到 AUTO 与您的问题的相关性 - 这只是让实现选择它想要使用的内容.

How could it "work properly" (you don't define basic info like what you mean by that) with Oracle ? I don't see the relevance of AUTO to your question - that simply lets an implementation choose what it wants to use.

"IDENTITY"(根据 JPA javadocs 和规范 - 您应该参考的内容)意味着 autoincrement.在 Oracle 中没有这样的概念,但在 MySQL、SQLServer 和其他一些中却有.我希望任何体面的 JPA 实现在尝试这样的事情时都会标记错误.

"IDENTITY" (as per JPA javadocs and spec - what you should be referring to) means autoincrement. There is no such concept in Oracle, yet there is in MySQL, SQLServer and a few others. I would expect any decent JPA implementation to flag an error when even trying such a thing.

Oracle 将允许使用SEQUENCE"或TABLE"策略

Oracle would allow "SEQUENCE", or "TABLE" strategies to be used however

这篇关于休眠中的 GenerationType.AUTO 与 GenerationType.IDENTITY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 03:45