-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate entry for key 'PRIMARY' With Play 1.5.0 + MySql #1227
Comments
Try disabling the new hibernate ID generator by adding this option to
More information: https://developer.jboss.org/thread/267613 |
Hi, Ps I have tried : |
Hey man, I work for a website for my school and our entire database was broken because we couldn't save anything. You have saved us all. You are a hero. |
had the same issuce, thanks @ludovicofischer |
Thank you @bastaware and @ludofischer for this thread, saved me hours! |
Ran into some trouble trying to upgrade 1.4.x to 1.5.0 - can't seem to find a migration guide?
After upgrading, when I save a class extending play.db.jpa.Model e.g.:
new Transaction(transDate, TransactionType.STOCK_BOUGHT, share, price, null).save();
The id of the record collides with existing entry and I get execeptions like:
Duplicate entry '9' for key 'PRIMARY'
At first it appeared to me that auto_increment of the table had been reset. But inserting manually worked fine.
Found this explanation:
https://vladmihalcea.com/why-should-not-use-the-auto-jpa-generationtype-with-mysql-and-hibernate/
Should play.db.jpa.Model be updated to use native, or should I simply make my own Model class ala:
@MappedSuperclass public class MyModel extends GenericModel { @Id @GeneratedValue( strategy= GenerationType.AUTO, generator="native" ) @GenericGenerator( name = "native", strategy = "native" ) public Long id; ...
The text was updated successfully, but these errors were encountered: