Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何解H2“;执行DDL时出错";错误?_Java_Hibernate_Spring Boot_Orm_H2 - Fatal编程技术网

Java 如何解H2“;执行DDL时出错";错误?

Java 如何解H2“;执行DDL时出错";错误?,java,hibernate,spring-boot,orm,h2,Java,Hibernate,Spring Boot,Orm,H2,我想在springboot中通过H2创建表,但运行时出现以下错误: org.hibernate.dialogue.dialogue:hh000400:使用方言: org.hibernate.dial.h2方言 org.hibernate.tool.schema.spi.CommandAcceptanceException:执行DDL“创建表银行账户(id bigint非空,余额)”时出错 double not null,全名varchar(128)not null,主键(id))“ 通过JDBC

我想在springboot中通过H2创建表,但运行时出现以下错误:

org.hibernate.dialogue.dialogue:hh000400:使用方言: org.hibernate.dial.h2方言 org.hibernate.tool.schema.spi.CommandAcceptanceException:执行DDL“创建表银行账户(id bigint非空,余额)”时出错 double not null,全名varchar(128)not null,主键(id))“ 通过JDBC语句

data.sql:

Insert into Bank_Account(ID, Full_Name, Balance) values (1, 'Ibrahim', 2500);
Insert into Bank_Account(ID, Full_Name, Balance) values (2, 'Ates', 4210);
pom.xml

<dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
我错过了什么


解决方案


问题是由实体的列名引起的。我已经将名为“全名”的实体更改为“全名”,然后问题就解决了

问题似乎是因为您试图使用hibernate auto ddl工具以及Spring Boots schema.sql文件初始化数据库

根据文件:

在基于JPA的应用程序中,您可以选择让Hibernate创建模式 或者使用
schema.sql
,但不能同时使用这两种方法。确保禁用 spring.jpa.hibernate.ddl-auto,如果使用
schema.sql


因此,要么删除
spring.jpa.hibernate.ddl auto=create
proprerty,要么删除
schema.sql
文件,这样spring Boot就不会尝试拾取它。

从应用程序中显示HibGenerate、db属性。属性文件我添加了问题的结尾…好的,有映射到银行账户表的实体吗?如果是,就给我看看。像下面我有@Entity@Table(name=“Bank_Account”)公共类BankAccount{…}嗨,我删除了schema.sql文件。但它仍然不起作用。
# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
# Datasource
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.continue-on-error=true
spring.jpa.hibernate.ddl-auto=create