大家好,
我有这个项目,在这里我使用ModelMapper将我的实体与DTO配对,反之亦然,并且还有一个具有@ElementCollection关系的类。 该映射器似乎对于所有其他方法都可以正常工作,并且它只是按照我的需要输出该实体,但是当涉及到删除映射时,我得到了以下错误以及500 http状态的输出。这是错误:
“ ModelMapper映射错误:\ r \ n \ r \ n1)转换器org.modelmapper.internal.converter.CollectionConverter@ddb7bc7无法将java.util.List转换为java.util.List。\ r \ n \ r \ n1错误”
这是代码:
实体类:
let data =["John Doe","Lutfur Kabir", "Moshiur Imtiaz Rahman", "Clark Kent","Jenny Doe"];
let result = data.reduce((r, c, i) => {
if(c.includes('Doe')) { r.push(i); }
return r;
}, []);
console.log(result);
DTO类:
webview
删除控制器:
@Entity
@Table(name = "quiz_engines")
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(
value = {"lastModified"},
allowGetters = true
)
public class Engine implements Model {
@Id
@Column(name = "engine_id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY,optional = false, targetEntity = com.QCMGenerator.QCMGenerator.Model.Test.class)
@JoinColumn(name = "test_id", referencedColumnName = "test_id", nullable = false, updatable = false)
@OnDelete(action = OnDeleteAction.NO_ACTION)
@JsonIgnore
private Test test;
@Column(name = "quiz_name", nullable = false)
@NotNull
private String name;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_modified", nullable = false)
@LastModifiedDate
private Date lastModified;
@ElementCollection
@CollectionTable(name = "engine_constraints", joinColumns = @JoinColumn(name = "engine_id"))
private List<EngineConstraint> constraints;
public Engine() {
}
public Engine(@NotNull String name, List<EngineConstraint> constraints) {
this.name = name;
this.constraints = constraints;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Test getTest() {
return test;
}
public void setTest(Test test) {
this.test = test;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getLastModified() {
return lastModified;
}
public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}
public List<EngineConstraint> getConstraints() {
return constraints;
}
public void setConstraints(List<EngineConstraint> constraints) {
this.constraints = constraints;
}
}
希望你们能为您提供帮助,感谢大家的宝贵时间,并祝您生活愉快。