Let's say I have:
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=truelogging.level.org.hibernate.SQL=DEBUG
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=create# Show or not log for each sql query
spring.jpa.show-sql = truespring.jpa.generate-ddl=true
spring.jpa.defer-datasource-initialization=true
My scripts are data.sql
:
INSERT INTO ITEMS(ITEM_ID, value) VALUES(1, 'EXAMPLE');
and the second script schema.sql
:
create table items
(
item_id int not null auto_increment,
value varchar(50) not null,
primary key (item_id)
);
The problem is when I'm using these configurations to populate automatically while running the project I'm getting the issue as in the full stacktrace
:
https://gist.github.com/invzbl3/abe68fe95c69b3a81699a2ed08375853#file-stacktrace-L111
Can someone tell me, please, am I missing something here?
Any smart ideas would be helpful here.
If I run it manually I don't have any issues, but while running the project to populate automatically I'm getting the issue as in the stacktrace.
UPD:
I've already tried this one, for example:
by changing the entity instead of this variant:
@Entity
@Table(name = "ITEMS")
public class Item {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Long id;
private String value;
}
to another one as:
@Entity
@Table(name = "`ITEMS`")
public class Item {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Long id;
private String value;
}
and as result I have: https://gist.github.com/invzbl3/83f00b9ca8d536052ac3174f7f9ddf47#file-stacktrace-L111
- And I've tried this: https://stackoverflow.com/a/44267377/8370915
by changing sql
script:
instead of:
INSERT INTO ITEMS(item_id, value)
VALUES (1, 'EXAMPLE');
to:
INSERT INTO ITEMS(item_id, value) VALUES (1, '`EXAMPLE`');
and as result I receive: https://gist.github.com/invzbl3/ae873cf7aaeeccfedff2dc5c8f543773#file-stacktrace-2-L111