2015-01-16 138 views
0

我試圖創建兩個實體之間的關係。
實體Fournisseur(ID,密碼,libelle)
實體目錄(ID,fournisseur_code)jhipster - 問題與兩個實體之間的自定義關係

我想這兩個實體之間的關係是代碼和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"/> 

該表是很好生成,但是當我米試圖運行GETALL它告訴我:

[錯誤] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - 在 '字段列表'

未知 列 'catalogue0_.fournisseur_id' 我想不通爲什麼。 如果有人知道....

謝謝。

回答

-1

該關係必須與該字段相關聯。 你必須改變:

baseColumnNames="fournisseur_code" 

這個

baseColumnNames="fournisseur_id" 
相關問題