【问题标题】:jhipster - issue with custom relationship between two entitiesjhipster - 两个实体之间的自定义关系问题
【发布时间】:2015-11-20 20:39:14
【问题描述】:

我正在尝试在两个实体之间建立关系。
实体 Fournisseur(id,code,libelle)
实体目录(id,fournisseur_code)

我希望这两个实体之间的关系在 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”列

我不知道为什么。 如果有人知道......

谢谢。

【问题讨论】:

    标签: liquibase jhipster


    【解决方案1】:

    关系必须与字段相关联。 你必须改变:

    baseColumnNames="fournisseur_code"
    

    到这里

    baseColumnNames="fournisseur_id"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      • 2015-05-23
      • 1970-01-01
      相关资源
      最近更新 更多