Есть абстрактный класс
@TypeAlias("DependencyParams")
public abstract class DependencyParams implements Cloneable {
...
}
У которого есть наследники
@TypeAlias("SimpleDependencyParams")
public class SimpleDependencyParams extends DependencyParams {
...
}
И класс, который хранит в себе поле с абстрактным типом
@Document(collection="devices")
@TypeAlias(value="Device")
@JsonTypeName("Device")
public class Device extends BasicEntity implements Cloneable {
private DependencyType dependencyType = DependencyType.SIMPLE;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "dependencyType", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = DependencyParams.class),
@JsonSubTypes.Type(value = SimpleDependencyParams.class, name = "SIMPLE")
})
private DependencyParams dependencyParams = new SimpleDependencyParams();
}
При доставании из БД объектов у меня происходит ошибка:
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate ....DependencyParams using constructor public ....DependencyParams() with arguments
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$MappingInstantiationExceptionEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:321) ~[spring-data-commons-2.5.6.jar:2.5.6]
...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [....DependencyParams]: Class is abstract
Это произошло после обновления spring data с 2.0.14.RELEASE до 3.2.6