[英]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.