Answer the question
In order to leave comments, you need to log in
How to correctly configure hibernate to use GenerationType.IDENTITY when adding a record to the DB?
I'm trying to figure out a bunch of spring jpa + hibernate. Initial data:
- DB - postgresql 10
- To generate the entity id, I use sequence in the database
- not SpringBoot - deploy war in Tomcat
Entity:
@Entity
@Table(name = "category")
public class Category {
@Id
@Column(name = "category_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
//остальные члены класса
}
@Repository
public interface CategoryRepository extends JpaRepository<Category, Integer> {
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question