0

问题:

Fasterxml 在 setter 中使用抽象时可以构造一个对象。请参阅下面的代码

Can not construct instance of CarState, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information

代码:

@MappedSuperclass
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
public interface IState {}

public class BusState implements IState{}

//register subtype in mapper
mapper.registerSubtypes(BusState .class);   

public interface Car {
  public void setState(IState state); 
}

@Entity
public class Bus implements Car {

  private BusState state;

  public void getState(BusState state) { //Seems fasterxml doesn't use this method, instead it use Car.setState
    this.state = state;
  }
}

我可以在课堂上创建两种不同的方法Bus:一种用于设置IState,另一种用于BusState. 但它看起来很丑。

问题:

我怎样才能让fasterxmlBus正确地构造-object?

4

0 回答 0