Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 具有继承性的Mapstruct映射器_Java_Spring_Mapstruct - Fatal编程技术网

Java 具有继承性的Mapstruct映射器

Java 具有继承性的Mapstruct映射器,java,spring,mapstruct,Java,Spring,Mapstruct,我有一个BaseEntity,它有一个名为Customer的子项 当我像这样制作mapper时: @Mapper(componentModel = "spring") public interface CustomerMapper { Customer toEntity(CustomerDTO model); List<Customer> toEntityList(List<CustomerDTO> models); CustomerDTO

我有一个BaseEntity,它有一个名为Customer的子项 当我像这样制作mapper时:

@Mapper(componentModel = "spring")
public interface CustomerMapper {

    Customer toEntity(CustomerDTO model);

    List<Customer> toEntityList(List<CustomerDTO> models);

    CustomerDTO toModel(Customer entity);

    List<CustomerDTO> toModelList(List<Customer> entities);

}
客户:

@EqualsAndHashCode(callSuper = true)
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Data
publi class Customer extends BaseEntity {

    private static final long serialVersionUID = 7054669140361044232L;


    @Column(length = 50, unique = true, nullable = false)
    private String login;


    @Column(name = "password_hash", nullable = false, length = 60)
    private String password;
}

我创建了一个示例来证明一切都按预期进行。请将此代码与您的代码进行比较,看看有什么不同。

我创建了一个示例来演示一切都按预期工作。请将此代码与您的代码进行比较,看看有什么不同。

这应该可以。你能在问题中添加“BaseEntity”、“Customer”和“CustomerTo”类的源代码吗?@Sudhir请检查我的更新
CustomerTo
是否有
id
uuid
字段?@MarcoLucidi是的,相同的类型和相同的名称这应该有效。你能在问题中添加“BaseEntity”、“Customer”和“CustomerDTO”类的源代码吗?@Sudhir请检查我的更新
CustomerDTO
是否有
id
uuid
字段?@MarcoLucidi是的,相同的类型和相同的名称
@EqualsAndHashCode(callSuper = true)
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Data
publi class Customer extends BaseEntity {

    private static final long serialVersionUID = 7054669140361044232L;


    @Column(length = 50, unique = true, nullable = false)
    private String login;


    @Column(name = "password_hash", nullable = false, length = 60)
    private String password;
}