gpt4 book ai didi

java - H2 数据库 : How to have lowercase for tablename?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:27:36 24 4
gpt4 key购买 nike

  • 我想将所有表名都保留为小写。示例

  • 我使用 Liquibase设置我的数据库,它看起来像

    <databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
    <changeSet author="harit" id="09222014.0639">
    <comment>Add Person Table</comment>
    <createTable tableName="person">
    <column name="id" type="INT"/>
    <column name="firstName" type="varchar(255)"/>
    <column name="lastName" type="varchar(255)"/>
    </createTable>
    </changeSet>
    </databaseChangeLog>

我使用 H2 数据库来运行我的集成测试并在 pom.xml 中设置为

   <cargo.datasource.datasource.earth>
cargo.datasource.driver=${h2.driver}|
cargo.datasource.url=${datasource.url}|
cargo.datasource.jndi=${datasource.jndi}|
cargo.datasource.username=${h2.user}|
cargo.datasource.password=${h2.user}
</cargo.datasource.datasource.earth>

datasource.url 看起来像

<datasource.url>jdbc:h2:${project.build.directory}/earth;DATABASE_TO_UPPER=false</datasource.url>

当我运行 mvn 时,我看到了

INFO 9/22/14 3:32 PM:liquibase: Successfully acquired change log lock
INFO 9/22/14 3:32 PM:liquibase: Dropping Database Objects in schema: UNIT-TESTING-PU.PUBLIC
INFO 9/22/14 3:32 PM:liquibase: Creating database history table with name: PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: Creating database history table with name: PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: Successfully released change log lock
INFO 9/22/14 3:32 PM:liquibase: Successfully acquired change log lock
INFO 9/22/14 3:32 PM:liquibase: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: Table person created
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: ChangeSet liquibase/2014/01.xml::09222014.0639::harit ran successfully in 1ms
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/01.xml::09222014.0639::harit: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: New row inserted into person
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: ChangeSet liquibase/2014/02.xml::09222014.0844::harit ran successfully in 3ms
INFO 9/22/14 3:32 PM:liquibase: liquibase/changelog.xml: liquibase/2014/02.xml::09222014.0844::harit: Reading from PUBLIC.DATABASECHANGELOG
INFO 9/22/14 3:32 PM:liquibase: Successfully released change log lock
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.929 sec
Running com.learner.integration.HelloIT
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.443 sec
Running com.learner.integration.PersonsIT
[INFO] [talledLocalContainer] 15:32:59,145 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-15) SQL Error: 42102, SQLState: 42S02
[INFO] [talledLocalContainer] 15:32:59,146 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-15) Table "Person" not found; SQL statement:
[INFO] [talledLocalContainer] select person0_.id as id1_0_, person0_.firstName as firstNam2_0_, person0_.lastName as lastName3_0_ from Person person0_ [42102-181]
[INFO] [talledLocalContainer] 15:32:59,153 ERROR [org.jboss.as.ejb3.invocation] (default task-15) JBAS014134: EJB Invocation failed on component PersonManager for method public java.util.List com.learner.business.manager.PersonManager.getPersons(): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
[INFO] [talledLocalContainer] at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
[INFO] [talledLocalContainer] at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
[INFO] [talledLocalContainer] at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:340) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
[INFO] [talledLocalContainer] at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
[INFO] [talledLocalContainer] at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
[INFO] [talledLocalContainer] at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
[INFO] [talledLocalContainer] at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

如您所见,liquibase 创建了 person 表,我为 H2 使用了 DATABASE_TO_UPPER=false,它来自 PERSONPerson

问题
我如何告诉 H2 我的表格都是小写的 -> person不是 Person

最佳答案

尝试在 H2 连接 URL 设置中使用“database_to_upper=false”。

关于java - H2 数据库 : How to have lowercase for tablename?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25984157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com