mapstruct-kotlin icon indicating copy to clipboard operation
mapstruct-kotlin copied to clipboard

Mapping of UUID to String error

Open AlehGalo opened this issue 4 years ago • 1 comments

I have an issue with Kotlin -> kapt -> mapstruct

I have 2 data classes

@Entity(name = "PLAN") @TypeDef(name = "pgsql_enum", typeClass = PostgreSQLEnumType::class) @KotlinBuilder data class Plan(

    @Id
    @GeneratedValue(generator = "UUID")
    @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
    @JsonProperty("uuid")
    val uuid: UUID? = null,

    @Column(nullable = false)
    val name: String,

...

@Document(collection = "plan") @KotlinBuilder data class MongoPlan(

    val uuid: String? = null,

    val name: String,

....

and mapping instructions

@Mapper interface MongoPlanMapper {

@Mappings(Mapping(target = "uuid",
        qualifiedByName = ["uuidMapper"]))
fun convert(plan: Plan): MongoPlan

@Named("uuidMapper")
fun uuidMapper(uuid: UUID): String =
        uuid.toString()

}

and I get

Error: java:".

AlehGalo avatar May 18 '20 20:05 AlehGalo

@AlehGalo Thank you for the report, first please make sure that the issue you mentioned is not only related to mapstruct. If you have time could you please provide me a very basic project where you can reproduce this issue ?

Pozo avatar Jul 25 '20 10:07 Pozo