Reputation: 14456
I get a list of @Entity
es for a query (so called Main Entities). I have to fill some of the Transient fields in these Entities with values from different queries / entities. So each of these transient fields needs different combination of fields from the Main Entities and based on that I should run query and fill the transient fields. These are done in 3 to 4 different methods.
My question is, what is the better approach in terms of performance and practice?
When you pass the entities to the methods, you are not creating copies, you are just passing original list? No performance related issues?
Upvotes: 0
Views: 1942
Reputation: 3442
Except for primitive types, every object passed to methods as parameter is passed as reference. Therefore you won't create copies of your entities if you pass a List<EntityClass>
object to your methods.
If there isn't any other reason not to do so, I would go with option 1 and pass the list of entities to the methods.
Upvotes: 1