Say we input username: hello
The entity below save the user info in User regU
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int user_id;
@Column(name = "username")
private String username;
The database already have 3 users with (auto_increment) id 1,2 and 3
Then we run the JPA save method:
URepo.save(regU)
Would the user normally get saved with id 4?
I tried test to this in my code, but when I run the save() method, literally nothing happens, hibernate doesn't show me the query it ran, no exception thrown, no changes in database.
My other queries print to console, but not save().
My JPA has these properties:
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="format_sql">true</prop>
<prop key="use_sql_comments">true</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
Edit 1: My current code gives the new entity the id of 0, how would spring-data save an id of 0, and is it normal for the new entity to have id of 0 rather than the auto_increment value?