我试图在两个实体之间建立关系
实体Fournisseur(id,code,libelle)
实体目录(id,fournisseur_code)
我希望这两个实体之间的关系介于代码和fournisseur_code之间。
我已经从
修改了实体目录的liquibase xml生成文件<changeSet id="20150116113044" author="jhipster"> <createTable tableName="T_CATALOGUE"> <column name="id" type="bigint" autoIncrement="true"> <constraints primaryKey="true" nullable="false"/> </column> <column name="fournisseur_id" type="bigint"/> <column name="produit_id" type="bigint"/> <column name="marque_id" type="bigint"/> <column name="pays_id" type="bigint"/> <column name="emballage_id" type="bigint"/> </createTable> <addForeignKeyConstraint baseColumnNames="fournisseur_code" baseTableName="T_CATALOGUE" constraintName="fk_catalogue_fournisseur_id" referencedColumnNames="id" referencedTableName="T_FOURNISSEUR"/>
到
<changeSet id="20150116113044" author="jhipster">
<createTable tableName="T_CATALOGUE">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="fournisseur_code" type="varchar(45)"/>
<column name="produit_id" type="bigint"/>
<column name="marque_id" type="bigint"/>
<column name="pays_id" type="bigint"/>
<column name="emballage_id" type="bigint"/>
</createTable>
<addForeignKeyConstraint baseColumnNames="fournisseur_code"
baseTableName="T_CATALOGUE"
constraintName="fk_catalogue_fournisseur_code"
referencedColumnNames="code"
referencedTableName="T_FOURNISSEUR"/>
该表生成良好,但当我尝试从CatalogueResource运行getAll函数时,它告诉我:
[错误] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - 未知 “字段列表”中的“catalogue0_.fournisseur_id”栏目
我无法弄清楚原因。 如果有人知道......
谢谢。
答案 0 :(得分:-1)
关系必须与字段相关联。 你必须改变:
baseColumnNames="fournisseur_code"
到这个
baseColumnNames="fournisseur_id"