Really quick post to a problem I’ve got un hibernate when converting to mySQL, I’ve found that the problem was because we were using a generator class “sequence” and in mySQL we needed to use “assigned” or “increment” instead.
Note you might not have that problem in your project but that was preventing me from creating my ids my mySQL db.
What are that generator class thing, well it how you generate your id. In oracle it usally use a sequence (hence the setting was sequence in hibernate) and mySQL didn’t support sequence at the time I was trying to convert it.
Sequence is safer if any other program/person is going to insert into the database table. Increment is less safer solution (but portable, to those db that don’t support Sequence) and good for testing and\or getting started. There are better ways than using Increment for use in production.
Note that you could use the generationType.AUTO and hibernate will produce the best strategy for you db.
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
Related:
How to have multiple database in a eclipse Java project (candidjava)
Changing database from Hibernate (stackoverflow)
Hibernate Generator class (javaTpoint)
Recent Comments