So, in services I’m often working with an Entity that’s passed in. I have no way to know what view/fetch plan it was loaded with, so no real way to know which attributes are available vs. which ones will cause a dreaded IllegalStateException
when accessed.
So, defensively I just reload it using a DataManager
call in the form of:
foo = dataManager.load(Foo.class).id(foo.getId()).fetchPlan("really-complete-foo-fetch-plan-that-has-all-the-attributes-because-illegalstateexceptions-suck").one();
This works, of course, and voila, no ISE’s, ever. But is this harming performance? Is there a better way? Is there a way to just force things to work more intelligently, and realize that if I want to access an attribute and it’s not loaded…perhaps the system should just load it on demand?