org.hibernate.exception.SQLGrammarException: could not prepare statement
In case of Spring-boot with H2 Database, need to use properties,
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Error was becoz Tables name and columns converted to UpperCase with underscore.
For example
createdOn -> CREATED_ON.
The table name you used, GROUP
, is a reserved keyword for h2 databases.
Rename your table with a name like ADMIN_GROUP
.
Here's an extract from the h2 documentation:
Keywords / Reserved Words
There is a list of keywords that can't be used as identifiers (table names, column names and so on), unless they are quoted (surrounded with double quotes). The list is currently:
CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT, EXCEPT, EXISTS, FALSE, FOR, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, LIKE, LIMIT, MINUS, NATURAL, NOT, NULL, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TRUE, UNION, UNIQUE, WHERE
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility, for example
CURRENT_TIMESTAMP
.
after about 40 minutes I found that user and currentUser should not be used as well
//this cause error
@Column()
private String user;
this causes: could not prepare statement; SQL [insert into table_progress (id, created, user, progress, updated, xdip) values (default, ?, ?, ?, ?, ?)]
//changed to this and works
@Column()
private String userP;