Lazy Load After Deserialization

M

Mark

I have some transient fields in an object. If the object is serialized
and deserialized, I don't want to fetch the values from the DAO unless
someone calls one of its getters or setters. I know I can add a check
in every method like:

public Item getItem()
{
if (_item == null)
return _dao.getItem();
else
return _item;
}

How can I avoid writing this check in every method? Is there an
elegant way to do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top