Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.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 映射实体,作为映射值列出。执行DDL时出错";如果存在“单行”,则删除表格;通过JDBC语句_Java_Mysql_Hibernate - Fatal编程技术网

Java 映射实体,作为映射值列出。执行DDL时出错";如果存在“单行”,则删除表格;通过JDBC语句

Java 映射实体,作为映射值列出。执行DDL时出错";如果存在“单行”,则删除表格;通过JDBC语句,java,mysql,hibernate,Java,Mysql,Hibernate,我正在尝试创建一个应用程序,将Csv文件保存到数据库中。 在编译时,我有一个错误,数据没有完全保存在MySql数据库中 CVS文件的每一行都是一个列表,它是映射的一部分。 实体的映射注释有问题吗 以下是实体: import javax.persistence.*; import java.util.Map; @Entity @Table(name = "map_of_single_lists") public class MapEntity { @Id @GeneratedValue(str

我正在尝试创建一个应用程序,将Csv文件保存到数据库中。 在编译时,我有一个错误,数据没有完全保存在MySql数据库中

CVS文件的每一行都是一个列表,它是映射的一部分。 实体的映射注释有问题吗

以下是实体:

import javax.persistence.*;
import java.util.Map;

@Entity
@Table(name = "map_of_single_lists")
public class MapEntity {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToMany(targetEntity=pl.manciak.excelparser.LinesEntity.class)
@MapKeyClass(Long.class)
private Map<Long, LinesEntity> mapa;

public MapEntity() {
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public Map<Long, LinesEntity> getMapa() {
    return mapa;
}

public void setMapa(Map<Long, LinesEntity> mapa) {
    this.mapa = mapa;
}
错误:

2020-02-25 14:40:35.187 DEBUG 6504 --- [           main] org.hibernate.SQL                        : alter table `map_of_single_lists_mapa` drop foreign key `FKqcxcam32e9xly5k8nqppj7t9u`
2020-02-25 14:40:35.203  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKqcxcam32e9xly5k8nqppj7t9u`" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKqcxcam32e9xly5k8nqppj7t9u`" via JDBC Statement


....


2020-02-25 14:40:35.204 DEBUG 6504 --- [           main] org.hibernate.SQL                        : alter table `map_of_single_lists_mapa` drop foreign key `FKmy4dokdghspd6asaa66i2r8lu`
2020-02-25 14:40:35.206  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKmy4dokdghspd6asaa66i2r8lu`" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKmy4dokdghspd6asaa66i2r8lu`" via JDBC Statement


....


2020-02-25 14:40:35.245 DEBUG 6504 --- [           main] org.hibernate.SQL                        : drop table if exists `single_line`
2020-02-25 14:40:35.248  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "drop table if exists `single_line`" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table if exists `single_line`" via JDBC Statement


....


2020-02-25 14:40:35.360 DEBUG 6504 --- [           main] org.hibernate.SQL                        : create table `single_line` (`id` bigint not null, primary key (`id`)) engine=InnoDB
2020-02-25 14:40:35.365  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "create table `single_line` (`id` bigint not null, primary key (`id`)) engine=InnoDB" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table `single_line` (`id` bigint not null, primary key (`id`)) engine=InnoDB" via JDBC Statement



好的,我把属性改为uptadte,它可以工作了。 spring.jpa.properties.hibernate.hbm2ddl.auto=update

但我仍然不确定映射是否正确。在数据库中我有23行,在csv文件中我有100行

spring.jpa.properties.hibernate.hbm2ddl.auto=create
logging.level.org.hibernate.SQL= DEBUG

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/newapp
spring.datasource.username=root
spring.datasource.password=1234
spring.h2.console.enabled=true
2020-02-25 14:40:35.187 DEBUG 6504 --- [           main] org.hibernate.SQL                        : alter table `map_of_single_lists_mapa` drop foreign key `FKqcxcam32e9xly5k8nqppj7t9u`
2020-02-25 14:40:35.203  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKqcxcam32e9xly5k8nqppj7t9u`" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKqcxcam32e9xly5k8nqppj7t9u`" via JDBC Statement


....


2020-02-25 14:40:35.204 DEBUG 6504 --- [           main] org.hibernate.SQL                        : alter table `map_of_single_lists_mapa` drop foreign key `FKmy4dokdghspd6asaa66i2r8lu`
2020-02-25 14:40:35.206  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKmy4dokdghspd6asaa66i2r8lu`" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table `map_of_single_lists_mapa` drop foreign key `FKmy4dokdghspd6asaa66i2r8lu`" via JDBC Statement


....


2020-02-25 14:40:35.245 DEBUG 6504 --- [           main] org.hibernate.SQL                        : drop table if exists `single_line`
2020-02-25 14:40:35.248  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "drop table if exists `single_line`" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table if exists `single_line`" via JDBC Statement


....


2020-02-25 14:40:35.360 DEBUG 6504 --- [           main] org.hibernate.SQL                        : create table `single_line` (`id` bigint not null, primary key (`id`)) engine=InnoDB
2020-02-25 14:40:35.365  WARN 6504 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "create table `single_line` (`id` bigint not null, primary key (`id`)) engine=InnoDB" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table `single_line` (`id` bigint not null, primary key (`id`)) engine=InnoDB" via JDBC Statement