java - Will Orika Map Complex Object having recursive structure? -
objective
my objective merge ui object presentation layer persistence object @ persistence layer. (detachcopy , update using jdo)
detail
want merge uiobject persistence object without loosing other states of persistence object. had tested use case orika. merged outer objects, internal objects creating new objects. loosing persistence states of persistence object, sets persistence layer.
complexity
outer fxuser object contains inner object childmetadata. childmetadata object contains list of outer fxuser object. @ level, object exist, need merge else need add. if source internal list does't have object, need removed desitination. equals , hash code overrided unique value.
mapperfactory factory = new defaultmapperfactory.builder().build(); boundmapperfacade<fxuserto, fxuservo> mapper = factory.getmapperfacade(fxuserto.class, fxuservo.class); mapper.map(sourcefxto, destinationfxvo);
my object structure give below ,
my object structure
persistence object
public class fxuservo implements talosvo { private int userid; private childmetadatavo childmetadata; .......other fields ..... getters , 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; fxuservo other = (fxuservo) obj; if (userid != other.userid) return false; return true; } } public class childmetadatavo implements talosvo { private list<fxuservo> childusers; .......other fields ..... getters , setters }
corresponding ui object
public class fxuserto implements talosto { private int userid; private childmetadatato childmetadata; .......other fields ..... getters , 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 , setters }
Comments
Post a Comment