You can also put :
@GeneratedValue(strategy = GenerationType.IDENTITY)
And let the DateBase manage the incrementation of the primary key:
AUTO_INCREMENT PRIMARY KEY
More Related Contents:
- How do I call the default deserializer from a custom deserializer in Jackson
- Avoid Jackson serialization on non fetched lazy objects
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- How can I log SQL statements in Spring Boot?
- @Transactional method called from another method doesn’t obtain a transaction
- No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor
- Exception NoClassDefFoundError for CacheProvider
- Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V
- What is the ‘best’ way to do distributed transactions across multiple databases using Spring and Hibernate
- Need to reset the value of sequence in Oracle
- mapping Hibernate query results to custom class?
- Spring 3.1 Hibernate 4 exception for Inheritance [cannot be cast to org.hibernate.mapping.RootClass]
- Java SE + Spring Data + Hibernate
- Spring hibernate template when to use and why?
- Could not commit JPA transaction: Transaction marked as rollbackOnly
- Change database schema during runtime based on logged in user
- Spring JpaRepository – Detach and Attach entity
- Rollback transaction after @Test
- Spring + Hibernate : a different object with the same identifier value was already associated with the session
- How to map sql native query result into DTO in spring jpa repository?
- javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional
- How to map a JSON column with H2, JPA, and Hibernate
- How to rollback a database transaction when testing services with Spring in JUnit?
- Spring 3.1, Hibernate 4, SessionFactory
- Spring, JPA, and Hibernate – how to increment a counter without concurrency issues
- How to setup Hibernate to read/write to different datasources?
- hibernate two tables per one entity
- Array with UserType in Hibernate and PostgreSQL –> MappingException
- How to make a database listener with java?
- How to use DTO in JSF + Spring + Hibernate