Reputation: 245
My configuration:
spring.datasource.url=jdbc:h2:mem:db;SCHEMA=public;DB_CLOSE_DELAY=-1;
JPA generates the following QUERY:
select itement0_.id as id1_0_, itement0_.brand as brand2_0_, itement0_._item_id as item3_0_, itement0_.product_group as product_4_0_ from public.item itement0_ where itement0_.item_id=? [42102-200]
which blows up with
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found; SQL statement
As far I can tell problem is h2 expect public schema in double quotes, so the following query works fine from h2 console:
select itement0_.id as id1_0_, itement0_.brand as brand2_0_, itement0_._item_id as item3_0_, itement0_.product_group as product_4_0_ from "public".item itement0_ where itement0_.item_id=? [42102-200]
My Entity:
@Getter
@Entity(name = "item")
@Table(name="item", schema = "public")
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class ItemEntity {
@Id
@GeneratedValue(generator="UUID")
private final UUID id;
@NotNull
@Column(unique = true)
private final String itemId;
private final String productGroup;
private final String brand;
}
Flyway creation script:
CREATE TABLE IF NOT EXISTS item
(
id uuid,
item_id VARCHAR,
product_group VARCHAR,
brand VARCHAR,
constraint pk_item PRIMARY KEY (id)
);
Does anyone know some workaround?
Upvotes: 2
Views: 3201
Reputation: 36103
You can add hibernate.globally_quoted_identifiers parameter to your application.properties:
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
Upvotes: 7