0
votes

I am working on a requirement where code should support oracle and MySQL databases. 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.

The documentation for GenerationType.AUTO says:

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

Its using table strategy for MySQL.

Please suggest how an Entity Identifier should be configured so that it uses the sequence for Oracle and Auto Increment for MySql.

1
look hereAnkur Singhal
Checked that already, but not willing to use table strategy as suggested in pointed URL.The thing is why hibernate is not picking Auto-increment for MySQL when GenerationType.AUTO is used. Thanks for pointer anyways.Puneet

1 Answers

1
votes

Worked well after disabling new generator mappings by adding below to hibernate properties.

hibernate.id.new_generator_mappings=false