Java Orika会映射具有递归结构的复杂对象吗?

Java Orika会映射具有递归结构的复杂对象吗?,java,orika,Java,Orika,目标 我的目标是将UI对象从表示层合并到持久层的持久化对象。(使用JDO进行复制和更新) 细节 要将UIObject合并到持久性对象而不丢失持久性对象的其他状态。我已经用Orika测试了用例。它成功地合并了外部对象,但对于内部对象,它将创建新对象。所以我失去了持久性对象的持久性状态,实际上是由持久性层设置的 复杂性 外部FXUser对象包含内部对象ChildMetaData。ChildMetaData对象包含外部FXUser对象的列表。在任何级别,对象都存在,需要合并,否则需要添加。如果源内部列

目标

我的目标是将UI对象从表示层合并到持久层的持久化对象。(使用JDO进行复制和更新)

细节

要将UIObject合并到持久性对象而不丢失持久性对象的其他状态。我已经用Orika测试了用例。它成功地合并了外部对象,但对于内部对象,它将创建新对象。所以我失去了持久性对象的持久性状态,实际上是由持久性层设置的

复杂性

外部FXUser对象包含内部对象ChildMetaData。ChildMetaData对象包含外部FXUser对象的列表。在任何级别,对象都存在,需要合并,否则需要添加。如果源内部列表没有对象,则需要将其从Destination中删除。等于,哈希代码被唯一值覆盖

 MapperFactory factory = new DefaultMapperFactory.Builder().build();

 BoundMapperFacade<FXUserTO, FXUserVO> mapper = 

 factory.getMapperFacade(FXUserTO.class, FXUserVO.class);

 mapper.map(sourceFxTO, destinationFxVO);
公共int hashCode(){

@凌驾 公共布尔等于(对象obj){

if(this==obj)
返回true;
if(obj==null)
返回false;
如果(getClass()!=obj.getClass())
返回false;
FXUserVO其他=(FXUserVO)obj;
if(userId!=other.userId)
返回false;
返回true;
}
}
公共类ChildMetaDataVO实现了TalosVO{
私人用户名单;
……其他领域
……接二连三
}
对应的UI对象

public class FXUserTO   implements TalosTO {

       private int userId;

       private ChildMetaDataTO childMetaData;    

       .......other fields 

     ..... getters and setters
@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + userId;
    return result;
}


@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    FXUserTO other = (FXUserTO) obj;
    if (userId != other.userId)
        return false;
    return true;
}
    }

public class ChildMetaDataTO   implements TalosTO {

   private List<FXUserTO> childUsers;

    .......other fields 

 ..... getters and setters

  }
public类FXUserTO实现TalosTO{
私有int用户id;
私有ChildMetaDataTO childMetaData;
……其他领域
……接二连三
@凌驾
公共int hashCode(){
最终整数素数=31;
int结果=1;
结果=prime*result+userId;
返回结果;
}
@凌驾
公共布尔等于(对象obj){
if(this==obj)
返回true;
if(obj==null)
返回false;
如果(getClass()!=obj.getClass())
返回false;
FXUserTO other=(FXUserTO)obj;
if(userId!=other.userId)
返回false;
返回true;
}
}
实现TalosTO的公共类ChildMetaDataTO{
私人用户名单;
……其他领域
……接二连三
}
  final int prime = 31;

  int result = 1;

  result = prime * result + userId;

  return result;

 }
if (this == obj)
    return true;

if (obj == null)
    return false;

if (getClass() != obj.getClass())
    return false;

FXUserVO other = (FXUserVO) obj;

if (userId != other.userId)
    return false;

return true;

 }

}

public class ChildMetaDataVO   implements TalosVO {

   private List<FXUserVO> childUsers;

    .......other fields 

 ..... getters and setters

  }
public class FXUserTO   implements TalosTO {

       private int userId;

       private ChildMetaDataTO childMetaData;    

       .......other fields 

     ..... getters and setters
@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + userId;
    return result;
}


@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    FXUserTO other = (FXUserTO) obj;
    if (userId != other.userId)
        return false;
    return true;
}
    }

public class ChildMetaDataTO   implements TalosTO {

   private List<FXUserTO> childUsers;

    .......other fields 

 ..... getters and setters

  }