You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

H2数据库JDBC连接URL中IGNROECASE参数不生效问题咨询

Alright, let's break this down. First off, that IGNORCASE=TRUE parameter you're using isn't doing what you think it does—it's meant for string value comparisons (like making WHERE name = 'foo' match 'FOO' too), not for handling case sensitivity of database identifiers like schemas or tables. That's why it isn't fixing your issue.

Fix 1: Use the Correct H2 Connection String Parameter

Instead of IGNORCASE=TRUE, you need to enable case-insensitive handling for identifiers. Add this to your JDBC URL:

CASE_INSENSITIVE_IDENTIFIERS=TRUE

So your full connection string might look like:

jdbc:h2:file:./your-db-file;CASE_INSENSITIVE_IDENTIFIERS=TRUE

This tells H2 to ignore case when matching schema, table, and column names—whether they're quoted or not. Note: This parameter was added in H2 version 1.4.197. If you're on an older version, you can use DATABASE_TO_UPPER=TRUE (which is the default, but worth explicitly setting) — this converts unquoted identifiers to uppercase automatically, so if Hibernate sends lowercase schema names without quotes, H2 will map them to your uppercase schema.

Fix 2: Tweak Hibernate's Naming Strategy

Hibernate often likes to convert entity/table names to lowercase by default, which clashes with your uppercase schema. Here's how to fix that:

If you're using Spring Boot:

Add this to your application.properties or application.yml:

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

This strategy preserves the exact case you specify in your entity annotations. So if you have an entity mapped to your uppercase schema:

@Entity
@Table(schema = "MY_SCHEMA", name = "MY_TABLE")
public class MyEntity {
    // ...
}

Hibernate will generate SQL that references MY_SCHEMA.MY_TABLE exactly, no automatic lowercase conversion.

For raw Hibernate (no Spring Boot):

Add this property to your hibernate.cfg.xml:

<property name="hibernate.physical_naming_strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</property>

Same effect—your explicit schema/table names in annotations are used as-is.

Fix 3: Watch Out for Quoted Identifiers

If your Hibernate naming strategy adds quotes around identifiers (some strategies do this for reserved words or camel-case names), quoted identifiers in H2 are case-sensitive by default. With CASE_INSENSITIVE_IDENTIFIERS=TRUE, this is no longer an issue, but if you're stuck on an older H2 version, make sure the quoted names match your uppercase schema exactly, or adjust the naming strategy to avoid quotes altogether.

Quick Check

Double-check that your schema creation SQL uses uppercase names (which you said it does) and that Hibernate isn't trying to create a new lowercase schema (if you have hibernate.hbm2ddl.auto set to create or update). If it is, you might need to adjust that setting or ensure the schema exists before your app starts.

内容的提问来源于stack exchange,提问作者Tom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 12:43:12