diff --git a/packages/cli/generators/relation/has-one-relation.generator.js b/packages/cli/generators/relation/has-one-relation.generator.js index 0b2008f280e4..2c4585ced1c0 100644 --- a/packages/cli/generators/relation/has-one-relation.generator.js +++ b/packages/cli/generators/relation/has-one-relation.generator.js @@ -106,7 +106,11 @@ module.exports = class HasOneRelationGenerator extends BaseRelationGenerator { ); relationUtils.addProperty(sourceClass, modelProperty); - const imports = relationUtils.getRequiredImports(targetModel, relationType); + const imports = relationUtils.getRequiredImports( + targetModel, + relationType, + sourceModel, + ); relationUtils.addRequiredImports(sourceFile, imports); await sourceFile.save(); @@ -159,6 +163,7 @@ module.exports = class HasOneRelationGenerator extends BaseRelationGenerator { const importsArray = super._getRepositoryRequiredImports( dstModelClassName, dstRepositoryClassName, + this.artifactInfo.srcModelClass, ); importsArray.push({ name: 'HasOneRepositoryFactory',