gpt4 book ai didi

java - JPA 2 : Benefits of @TableGenerator

转载 作者:行者123 更新时间:2023-12-02 00:04:36 26 4
gpt4 key购买 nike

@TableGenerator 技术生成主键有什么好处?为什么我们使用这种技术以及如何使用用于存储生成器的序列名称和值的第三个表来获取数据?

最佳答案

来自链接。 http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Table_sequencing

There are several strategies for generating unique ids. Some strategies are database agnostic and others make use of built-in databases support. JPA provides support for several strategies for id generation defined through the GenerationType enum values: TABLE, SEQUENCE and IDENTITY. The choice of which sequence strategy to use is important as it affects performance, concurrency and portability.

因此,选择使用表生成器可以使您免于使用数据库特定功能。这使得以后可以轻松地将数据库迁移到其他数据库提供商。因此,应该根据您是否想要稍后迁移数据库提供程序、为此牺牲多少性能等来做出决定。

关于java - JPA 2 : Benefits of @TableGenerator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14118491/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com