getEntityModel on @ExernalEntity anntotated class fails when called more than once
Description Suppose we have the following:
public class ThirdPartyEntity {
public String field;
public Long number;
}
and
@ExternalEntity(target = ThirdPartyEntity.class)
public class ThirdPartyEntityMixIn {
public String field;
@Id
public Long number;
}
When calling datastore.getMapper().getEntityModel(ThirdPartyEntityMixIn.class), the entity model of ThirdPartyEntity is returned correctly the first time. However, on the second call, getEntityModel fails due to a duplicated discriminator error:
Two entities have been mapped using the same discriminator value (com.example.ThirdPartyEntityMixIn): com.example.ThirdPartyEntity and com.example.ThirdPartyEntity
Cause The issue occurs because when entities are being put into mappedEntities, the key used is entityModel.getType(), which refers to ThirdPartyEntity.class. But when retrieving the model in getEntityModel, the key used is ThirdPartyEntityMixIn.class, leading to a conflict when Morphia attempts to register the entity again.
Morphia Version: 2.4.4
I'll try to dig in to this tonight.
Well, "tonight" turned in to months. I can't recreate this on master/2.4.14. If you could put together a reproducer I'd be happy to take another look. For now I'll remove this from 2.4.15 because we're long overdue for a release.