'Model mapper map generic field

I am using ModelMapeer library and trying to add a custom mapping. I have abstract entity:

public abstract class AbstractEntity<ID extends Serializable> {
     private ID id;
}

and child entity

public class User extends AbstractEntity<UUID> {
     //fields
}

so I am trying to add custom mapping like this

this.typeMap(User.class, UserDetailsDto.class)
            .addMappings(mapper -> mapper.map(User::getId, UserDetailsDto::userId));

and getting this exception:

java.lang.ClassCastException: class java.io.Serializable$ByteBuddy$lX3s11ID cannot be cast to class java.util.UUID

What do I need to change in a mapping(not entities) to resolve this? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source