我有 Exec 实体:
@Entity("Exec")
public class Exec {
@Id
private ObjectId id;
private long initDate;
private long endDate;
public enum statuses {
SUCCESS, FAIL, PARTIAL
}
private statuses status;
@Reference(idOnly = true, ignoreMissing = true, lazy = false)
Analysis analysis;
@Reference(idOnly = true, ignoreMissing = true, lazy = true)
Set<Conclusion> conclusions = new HashSet<Conclusion>();
// getters and setters
引用了结论实体:
@Entity("Conclusion")
public class Conclusion {
@Id
private ObjectId id;
private Map<String, Object> params = new HashMap<String, Object>();
private long initDate;
private long endDate;
public enum statuses {
SUCCESS,
FAILURE
}
private statuses status;
private String errorMessage;
private String stackTrace;
Set<Map<String, Object>> data = new HashSet<Map<String, Object>>();
在调试器中,如果我试图得出结论
Set<Conclusions> conclusions = mongoWrapper.getDataStore().createQuery(Exec.class).asList().get(0).getConclusions()
我收到以下消息:
com.sun.jdi.InvocationException occurred invoking method.
如果我尝试访问该对象,例如,执行以下操作:
conclusions.toArray()
它抛出RuntimeException,检查堆栈跟踪:
org.mongodb.morphia.mapping.MappingException: Embedded element isn't a DBObject! How can it be that is a class java.lang.String
我尝试改变一堆东西,没有什么真正有效。关于问题的关键是什么想法?
答案 0 :(得分:0)
在一组结论中使用具体的AnalysisConclusion。 请记住,注释不是继承的,然后使用@Entity
标记AnalysisConclusion