I have the following in my code:
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
And, I noted when I have the @GeneratedValue
it simply does not generate my MySql tables, yet without that annotation it generates the respective tables.
What are the key points I should be checking for ?
This is very tricky,as you might believe that you have define all the properties of hibernate properly and with the addition of @GeneratedValue annotation resulting a SQL Gram-mer error. Yet, I was able to resolve this by exploring the hibernate properties more carefully. Specifically look for the below properties in the hibernate configuration. property name="hibernateProperties">
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=create
for the hibernate.dialect --> you should have org.hibernate.dialect.MySQL5InnoDBDialect yet you might see, it also generates table for -> org.hibernate.dialect.SQLServerDialect in MySQL database, which push you to a conclusion that you have set the hibernate properties properly. If any of your metadata annotation produces a grammer error, I strongly suggest you to check the hibernate properties
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.