java - Weird copy constructor -
i have 2 classes: abstractmailingdirections
, directionload
. both have copy constructor follows:
public abstractmailingdirections(abstractmailingdirections tocopy) { this.message = tocopy.message; this.defaultdirection = new directionload(tocopy.defaultdirection); (final directionload dls : tocopy.directionloads) { this.directionloads.add(new directionload(dls)); } }
and
public directionload(directionload tocopy) { this.direction = tocopy.direction; this.transportationcontract = tocopy.transportationcontract; this.pickuptime = tocopy.pickuptime; this.acceptancetime = tocopy.acceptancetime; this.acceptancelocation = tocopy.acceptancelocation; this.information = tocopy.information; }
now when call mailingdirections
copy constructor (which super(tocopy)
) don't fields of defaultdirection
copied. or not of them. , using eclipse debugger stranger:
here have clicked on abstractmailingdirections
copied. see how defaultdirection.acceptancetime
17:00 in tostring
print shows null
in field listing. if click defaultdirection, it's tostring
print show acceptancetime
field null
.
this driving me nuts. ideas causing this?
are these hibernate entities (or jpa or similar)? in case accessing fields might brake lazy loading magic & accessing through getters might fix it.