MANAGED_CLASS_MAPPING_ERROR给定javaClass'类java.util.ArrayList'映射到ListType,期望ManagedType

时间:2016-02-06 14:17:39

标签: javers

我们正在开始在我们的应用程序中试验JaVers。我们希望在用户下订单后跟踪订单的更改。所以它是您的主要订单对象,项目,项目选项等的典型订单对象。大约一半的时间我们运行测试程序,我们收到此异常:

  

130 [main] INFO org.javers.core.JaversBuilder - JaVers实例已启动   &安培;准备好线程中的异常" main" JaversException:   给定javaClass'类的MANAGED_CLASS_MAPPING_ERROR   的java.util.ArrayList'映射到ListType,期望ManagedType at   org.javers.core.metamodel.type.TypeMapper.getJaversManagedType(TypeMapper.java:149)     在   org.javers.core.metamodel.type.TypeMapper.getJaversManagedType(TypeMapper.java:132)     在   org.javers.core.metamodel.object.GlobalIdFactory.createId(GlobalIdFactory.java:39)     在   org.javers.core.graph.LiveCdoFactory.create(LiveCdoFactory.java:24)     在org.javers.core.graph.EdgeBuilder.asCdo(EdgeBuilder.java:39)at   org.javers.core.graph.EdgeBuilder.buildSingleEdge(EdgeBuilder.java:32)     在   org.javers.core.graph.ObjectGraphBuilder.buildSingleEdges(ObjectGraphBuilder.java:81)     在   org.javers.core.graph.ObjectGraphBuilder.buildEdges(ObjectGraphBuilder.java:71)     在   org.javers.core.graph.ObjectGraphBuilder.buildGraphFromCdo(ObjectGraphBuilder.java:59)     在   org.javers.core.graph.ObjectGraphBuilder.buildGraph(ObjectGraphBuilder.java:48)     在   org.javers.core.graph.LiveGraphFactory.createLiveGraph(LiveGraphFactory.java:39)     在org.javers.core.diff.DiffFactory.buildGraph(DiffFactory.java:109)     在org.javers.core.diff.DiffFactory.compare(DiffFactory.java:64)at   org.javers.core.JaversCore.compare(JaversCore.java:104)

我们只是重新运行程序并最终运行。代码基本上就是这样。

// Original database object
OrderVO oldOrder = // load from database.

// Changed database object
OrderVO newOrder = // load from database.
// Change the email
newOrder.setEmail("test@test.com");
// Simulate changing quantity and item id on items
for (OrderItemVO OrderItemVO : newOrder.getItems()) {
  OrderItemVO.setMerchantItemId(OrderItemVO.getMerchantItemId() + "A");
  OrderItemVO.setQuantity(OrderItemVO.getQuantity().add(1));
}

// Remove the first item
OrderItemVO[] items = new OrderItemVO[newOrder.getItems().length - 1];
System.arraycopy(newOrder.getItems(), 1, items, 0, items.length);
newOrder.setItems(items);

// Run comparison
Javers javers = JaversBuilder.javers().withListCompareAlgorithm(ListCompareAlgorithm.LEVENSHTEIN_DISTANCE).build();
Diff diff = javers.compare(oldOrder, newOrder);

0 个答案:

没有答案