JHipster:Relation" datcat_attribute_metadata"不存在

时间:2017-06-12 22:05:04

标签: jhipster

JHipster没有为数据库创建表 DatcatAttributeMetadata 。这是一个子表,其外键关系manyToOne与父表DatcatAttributeMetadata。 父表是先前创建的,但是在使用Jhipster实体模块添加DatcatAttributeMetadata时,此表未添加到PostgresSql并抛出错误ERROR:relation" datcat_attribute_metadata"不存在

已尝试过--force-entity和mvn liquidbase:diff多次但仍未在DB中创建表

以下是

的代码段
  • master.xml
  • 20170612191949_added_entity_constraints_DatcatAttributeMetadata.xml
  • 20170612191949_added_entity_DatcatAttributeMetadata.xml

    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

    <include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
    <include file="classpath:config/liquibase/changelog/20170612161115_added_entity_DatcatDatasetMetadata.xml" relativeToChangelogFile="false"/>
    <include file="classpath:config/liquibase/changelog/20170612191949_added_entity_DatcatAttributeMetadata.xml" relativeToChangelogFile="false"/>
    <!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
    <include file="classpath:config/liquibase/changelog/20170612191949_added_entity_constraints_DatcatAttributeMetadata.xml" relativeToChangelogFile="false"/>
    <!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
    

    <?xml version="1.0" encoding="utf-8"?>
    <databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
        <!--
            Added the constraints for entity DatcatAttributeMetadata.
        -->
        <changeSet id="20170612191949-2" author="jhipster">
    
            <addForeignKeyConstraint baseColumnNames="dataset_id_id"
                                     baseTableName="datcat_attribute_metadata"
                                     constraintName="fk_datcat_attribute_metadata_dataset_id_id"
                                     referencedColumnNames="dataset_id"
                                     referencedTableName="datcat_dataset_metadata"/>
    
        </changeSet>
    </databaseChangeLog>
    

    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd                         http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd&#34;&gt;

    <property name="now" value="now()" dbms="h2"/>
    
    <property name="now" value="current_timestamp" dbms="postgresql"/>
    
    <property name="floatType" value="float4" dbms="postgresql, h2"/>
    <property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
    
    
    <changeSet id="20170612191949-1" author="jhipster">
        <createTable tableName="datcat_attribute_metadata">
            <column name="attribute_id" type="bigint" autoIncrement="${autoIncrement}">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="attribute_def" type="varchar(255)">
                <constraints nullable="false" />
            </column>
    
            <column name="primary_key" type="boolean">
                <constraints nullable="false" />
            </column>
    
            <column name="foreign_key" type="varchar(255)">
                <constraints nullable="true" />
            </column>
    
            <column name="attribute_datatype" type="varchar(255)">
                <constraints nullable="false" />
            </column>
    
            <column name="attribute_lenght" type="integer">
                <constraints nullable="true" />
            </column>
    
            <column name="dataset_id_id" type="bigint">
                <constraints nullable="false" />
            </column>
    
            <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
        </createTable>
    
    </changeSet>
    

日志

2017-06-12 16:15:01.198 DEBUG 44521 --- [  XNIO-2 task-3] c.e.p.d.apis.aop.logging.LoggingAspect   : Enter: com.exelon.predix.datacatalog.apis.web.rest.DatcatAttributeMetadataResource.getAllDatcatAttributeMetadata() with argument[s] = [Page request [number: 0, size 20, sort: id: ASC]]
2017-06-12 16:15:01.207 DEBUG 44521 --- [  XNIO-2 task-3] .d.a.w.r.DatcatAttributeMetadataResource : REST request to get a page of DatcatAttributeMetadata
2017-06-12 16:15:01.210 DEBUG 44521 --- [  XNIO-2 task-3] c.e.p.d.apis.aop.logging.LoggingAspect   : Enter: com.exelon.predix.datacatalog.apis.service.DatcatAttributeMetadataService.findAll() with argument[s] = [Page request [number: 0, size 20, sort: id: ASC]]
2017-06-12 16:15:01.210 DEBUG 44521 --- [  XNIO-2 task-3] a.s.i.DatcatAttributeMetadataServiceImpl : Request to get all DatcatAttributeMetadata
Hibernate: select datcatattr0_.attribute_id as attribut1_0_, datcatattr0_.attribute_datatype as attribut2_0_, datcatattr0_.attribute_def as attribut3_0_, datcatattr0_.attribute_lenght as attribut4_0_, datcatattr0_.dataset_id_dataset_id as dataset_7_0_, datcatattr0_.foreign_key as foreign_5_0_, datcatattr0_.primary_key as primary_6_0_ from datcat_attribute_metadata datcatattr0_ order by datcatattr0_.attribute_id asc limit ?
2017-06-12 16:15:01.223  WARN 44521 --- [  XNIO-2 task-3] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 42P01
2017-06-12 16:15:01.223 ERROR 44521 --- [  XNIO-2 task-3] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: relation "datcat_attribute_metadata" does not exist
  Position: 331
2017-06-12 16:15:01.237 ERROR 44521 --- [  XNIO-2 task-3] c.e.p.d.apis.aop.logging.LoggingAspect   : Exception in com.exelon.predix.datacatalog.apis.service.DatcatAttributeMetadataService.findAll() with cause = 'org.hibernate.exception.SQLGrammarException: could not extract ResultSet' and exception = 'could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet'

请不要通过更改liquidbase文件并在域类中使用@Column注释,将父表和子表中主键的列名更新为dataset_id和attribute_id。

0 个答案:

没有答案