简体   繁体   English

GenerationType.AUTO没有选择适当的策略

[英]GenerationType.AUTO not picking appropriate strategy

I am working on a requirement where code should support oracle and MySQL databases. 我正在研究代码应支持oracle和MySQL数据库的要求。 We are using hibernate and trying to achieve the same using framework capabilities.For Identity columns, we are using @GeneratedValue annotation to manage auto-generated IDs keeping strategy as GenerationType.AUTO. 我们正在使用休眠模式并尝试使用框架功能来实现相同的功能。对于Identity列,我们使用@GeneratedValue批注来管理自动生成的ID,并将策略保持为GenerationType.AUTO。

The documentation for GenerationType.AUTO says: GenerationType.AUTO的文档说:

Indicates that the persistence provider should pick an appropriate strategy for the particular database. 指示持久性提供程序应为特定数据库选择适当的策略。

Its using table strategy for MySQL. MySQL的使用表策略。

Please suggest how an Entity Identifier should be configured so that it uses the sequence for Oracle and Auto Increment for MySql. 请建议如何配置实体标识符,以便它使用Oracle序列和MySql自动增量序列。

通过将以下内容添加到休眠属性来禁用新的生成器映射后,效果很好。

hibernate.id.new_generator_mappings=false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EclipseLink和H2策略= GenerationType.AUTO - EclipseLink and H2 strategy = GenerationType.AUTO Hibernate @GeneratedValue(strategy = GenerationType.AUTO) - Hibernate @GeneratedValue(strategy = GenerationType.AUTO) JPA @GeneratedValue(strategy=GenerationType.AUTO) 在 MySQL 上不起作用 - JPA @GeneratedValue(strategy=GenerationType.AUTO) does not work on MySQL 休眠Junit hsqldb-(strategy = GenerationType.AUTO)不起作用 - Hibernate Junit hsqldb - (strategy = GenerationType.AUTO) not working 休眠:在以下情况下插入具有自定义ID的实体:strategy = GenerationType.AUTO - Hibernate: inserting an entity with custom id in the case: strategy = GenerationType.AUTO oracle上的Hibernate序列,@ GeneratedValue(strategy = GenerationType.AUTO) - Hibernate sequence on oracle, @GeneratedValue(strategy = GenerationType.AUTO) 使用@GeneratedValue(strategy = GenerationType.AUTO)时,Hibernate不保存对象 - Hibernate does not save Object when using @GeneratedValue(strategy=GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO): MySQL 和表之间共享的生成ID? - @GeneratedValue(strategy = GenerationType.AUTO): MySQL and generated IDs shared between tables? 为什么GenerationType.AUTO在PostgreSQL上没有使用串口? - Why is GenerationType.AUTO not using a serial on PostgreSQL? JPA GenerationType.AUTO并手动设置字段 - JPA GenerationType.AUTO and setting the field manually
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM