I have two classes: AbstractMailingDirections and DirectionLoad. Both have a copy constructor as follows:
public AbstractMailingDirections(AbstractMailingDirections toCopy) {
    this.message = toCopy.message;
    this.defaultDirection = new DirectionLoad(toCopy.defaultDirection);
    for (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 I call the MailingDirections copy constructor (which is just super(toCopy)) I sometimes don't get fields of the defaultDirection copied. Or not all of them. And using a Eclipse debugger is even stranger:
here I have clicked on the AbstractMailingDirections to be copied. See how defaultDirection.acceptanceTime is 17:00 in the toString print but shows up null in the field listing. If I click the defaultDirection, it's toString print will show the acceptanceTime field as null.
This is driving me nuts. Any ideas what could be causing this?
Are these Hibernate entities (or JPA or similar)? In that case accessing the fields might brake the lazy loading magic & accessing it through getters might fix it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With