首页 > 解决方案 > jhipster中多对多关系的问题

问题描述

我有一个非常痛苦的错误,四天以来我一直在寻找解决方案。所以我想用 jhipster 命令在两个实体文件夹和客户端之间建立多对多关系,并且文件夹实体是关系的持有者。因此,在创建关系后,我尝试发布客户,但出现此错误:

could not prepare statement; SQL [insert into client (firstname, lastname, username, id) values (?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement",

当我试图获取一个文件夹时,我得到了那个错误: could not prepare statement; SQL [select distinct folder0_.id as id1_2_0_, client2_.id as id1_0_1_, folder0_.author as author2_2_0_, folder0_.deposit_date as deposit_3_2_0_, folder0_.identifier as identifi4_2_0_, folder0_.metadata_1 as metadata5_2_0_, folder0_.metadata_2 as metadata6_2_0_, folder0_.metadata_3 as metadata7_2_0_, client2_.firstname as firstnam2_0_1_, client2_.lastname as lastname3_0_1_, client2_.username as username4_0_1_, clients1_.folders_id as folders_1_3_0__, clients1_.clients_id as clients_2_3_0__ from folder folder0_ left outer join folder_client clients1_ on folder0_.id=clients1_.folders_id left outer join client client2_ on clients1_.clients_id=client2_.id]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement",

两个实体中的关系代码如下:

文件夹侧: @ManyToMany @JoinTable(name = "folder_client", joinColumns = @JoinColumn(name = "folders_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "clients_id", referencedColumnName = "id")) private Set<Client> clients = new HashSet<>();

和客户端: @ManyToMany(mappedBy = "clients") @JsonIgnore private Set<Folder> folders = new HashSet<>();

那么有人知道如何解决这个问题吗???谢谢:) :)

标签: many-to-manyjhipsterh2

解决方案


推荐阅读