When you call a method in Java, what gets passed is a copy of the reference to the object in memory — not the object itself, but not a deep copy either.
That means both variables (the one in your service, and the one inside your helper) point to the same exact object stored in the heap.
You have this line:
offerAdminMapperHelper.setCreateRelations(offerCreateAdminRequest, offer);
Let’s look at what’s going on under the hood.
Offer offer = offerAdminMapper.toEntity(product);
At this moment, a new Offer object is created somewhere in the heap memory.
Imagine the JVM creates it and gives it an address — let’s say 0xABC123.
In the JVM’s memory:
Heap:
Offer@0xABC123 {
organization = null
user = null
employee = null
accountManager = null
}
Stack (your createOffer() method):
offer → points to 0xABC123
So your local variable offer doesn’t contain the Offer itself —
it contains a reference (a kind of “pointer”) that says “the Offer lives at address 0xABC123”.
offerAdminMapperHelper.setCreateRelations(offerCreateAdminRequest, offer);