You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating this thread to share some of the problems that I faced at the end of the chapter 3 after migration to JPA. I believe the steps provided in the book are not enough and I had to change some of the things to make the things work.
Feel free to add your experience in this.
The text was updated successfully, but these errors were encountered:
Issue:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Sequence "HIBERNATE_SEQUENCE" not found; SQL statement:
call next value for hibernate_sequence [90036-214]
Solution:
The error message suggests that the sequence "HIBERNATE_SEQUENCE" is not found in the H2 database. This sequence is commonly used by Hibernate to generate unique IDs for entities.
So, please add below line in the "schema.sql" file:
CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1 INCREMENT BY 1;
Issue:
insert into Taco_Ingredient (Taco_id, ingredients_id) values (?, ?) [42122-214]
2023-05-05 00:58:39.753 ERROR 35536 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [insert into Taco_Ingredient (Taco_id, ingredients_id) values (?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement] with root cause
org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "TACO_ID" not found; SQL statement:
insert into Taco_Ingredient (Taco_id, ingredients_id) values (?, ?) [42122-214]
Solution:
Change the schema and add Taco_id and ingredients_id in respective tables because when you added @manytomany annotation in the beans of Taco and Ingredient then the JPA would by default first find the table Taco_Ingredient by combining these two and then find its primary keys by following [fieldName in beans class on which ManytoMany annotaiton is added] + "_" + "id"
I am creating this thread to share some of the problems that I faced at the end of the chapter 3 after migration to JPA. I believe the steps provided in the book are not enough and I had to change some of the things to make the things work.
Feel free to add your experience in this.
The text was updated successfully, but these errors were encountered: