简体   繁体   English

Jhipster:如何使用字段而不是ID创建关系

[英]Jhipster: How to create a relationship using a field not the id

I have 2 entities Country abd competions and i want to build a relationship betwenn them using the isoCode of the country, but when i generate the database(mySql) i find that the relation is based on the generated country_id. 我有2个实体Country abd竞争,我想使用国家的isoCode在它们之间建立关系,但是当我生成数据库(mySql)时,我发现该关系基于生成的country_id。 What i'm missing? 我想念的是什么? Can i specify my own id and remove the generated id from the jdl file? 我可以指定自己的ID并从jdl文件中删除生成的ID吗?

entity Country {
    isoCode String required
    .
    .
}

entity Competition {
    priority Integer,
    code String,
    name String
}

relationship OneToMany {
    Country to Competition{country(isoCode)}, 

   }

Thanks 谢谢

JHipster仅支持关系的技术ID,如果要使用业务ID,则必须手动对其进行编码,也许可以看看Hibernate @NaturalId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改Jhipster中实体的默认ID字段的名称和值 - How to change the name and value of default ID field of an entity in jhipster 如何在使用存储过程时创建自动增加的 id 字段? - How to create id field with auto increasement while using stored procedure? 如何使用 Python 在 MySQL 中创建唯一 ID 字段 - How to create a unique ID field in MySQL using Python 如何使用Elasticsearch重命名实体中的ID字段? - How to rename id field in an entity using with elasticsearch? 如何在JHipster中向JHI_USER添加新字段 - How to add new field to JHI_USER in JHipster 如何动态创建与表中的ID相关的所有字段值的视图? - How to dynamically create a view of all the field values related to an id in a table? 如何在MySQL中为两个单独的表创建自动增量ID字段? - How to create auto increment ID field for two separate tables in MySQL? 如何使用sequelize和mysql创建一对一关系? - How to create a one-to-one relationship using sequelize and mysql? MySQL:在将表值设置为默认值之后,如何更新外键字段并创建关系? - MySQL: How to update foreign key field, and create a relationship, after table values have been set with default values? 如何在与外键和主键没有相同字段的两个表之间创建关系 - How to create relationship between two tables which have no same field as foreign key and primary key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM