jadhamterra
jadhamterra

Reputation: 17

Application failed after spring boot upgrade to 2.7.x Error executing DDL

After upgrading spring boot from version 2.6.3 to 2.7.3, I have a problem with the H2 database (after the spring boot upgrade, apparently the h2 database also got an upgrade).

After launching the application I get Error:

GenerationTarget encountered exception accepting command : Error executing DDL "create table appa_attributes (id bigint generated by default as identity, name varchar(255), value varchar(4000), primary key (id))" via JDBC Statement org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table appa_attributes (id bigint generated by default as identity, name varchar(255), value varchar(4000), primary key (id))" via JDBC Statement

application.properties:

server.port=8080
spring.mvc.favicon.enabled = false // this in version 2.7 is deprecated
spring.datasource.url=jdbc:h2:mem:testdb
spring.h2.console.enabled=true
spring.h2.console.path=/console/
spring.h2.console.settings.web-allow-others=true
spring.jpa.hibernate.ddl-auto=create-drop

Attribute.java (this is how the table is defined)

@Entity
@Table(name = "appa_attributes")
public class Attribute extends AbstractEntity<Long> implements Comparable<Attribute> {

    @Column(length = 255)
    private String name;

    @Column(length = 4000)
    private String value;

//getters and setter

Upvotes: 1

Views: 1108

Answers (1)

Evgenij Ryazanov
Evgenij Ryazanov

Reputation: 8188

The best choice here is to rename the column with something like @Column(name = "ATT_VALUE", length = 4000), you don't need to rename your field in entity.

Alternatively you can force quotation of all identifiers by setting hibernate.globally_quoted_identifiers to true (in the Spring configuration it will be spring.jpa.properties.hibernate.globally_quoted_identifiers=true).

In the worst case you can add ;NON_KEYWORDS=USER to JDBC URL of H2, but you should understand that this setting isn't very reliable and may not work in all cases.

Upvotes: 1

Related Questions