playframework / playframework/play1

mysql primary key can not auto_increment

Open
#1,288 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.6k
Forks
671
Avg merge
12d 15h
Merged PRs (30d)
1

Description

I am using a MySQL database. The table I created is self-growth. The mapped java entity inherits the play.db.jpa.Model class, but when I call the .save() method to save it to the database, The primary key ID is generated by hibernate_sequence, not by the table AUTO_INCREMENT.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with a MySQL table using AUTO_INCREMENT and a Java entity inheriting play.db.jpa.Model. Inspect how save() selects the identifier generator and compare the generated hibernate_sequence value with the table's AUTO_INCREMENT behavior. Done means saving the entity uses the table's auto-generated primary key and populates the mapped ID correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.