A session attribute must be a String or a primitive. The session doesn’t allow storing of arbitrary objects. It’s intended as a simple mechanism to store basic data (not an object graph)."
Why is this limitation in place? I really need to store some simple POJO objects (not a full graph) otherwise I need to break them down into Strings and build them up i.e. convert to/from JSON or something.
Since its inception Java has allowed HttpSession.setAttribute(name, value). I get that some have abused this mechanism with complex graphs and can run out of memory if they don't release references, etc... but on the other hand this complicates dealing with simple POJO's... e.g. load a User object from DB to display name, get their role, etc....
What am I missing here and what's the best advice if I need to store some simple objects that are not Strings or Primitives?
Thank You,
--Nikolaos