Hello again,

a slightly different topic as the last but with the same "undertones":

I need a session storage where I store the currently logged on user. Reading 
about it in the documentation, they recommend using @SessionState because my 
user is a complex object, also containing lists of other entities.

My user also is an entity in a database. So, when a user logs in, the 
appropriate entity is retrieved from the database, an "AppSession" object is 
created containing, among e.g. the time of login, the user object. Is this the 
right way to do it? Or should I only store the ID in the session?

Now when the SessionState object is created, it can be used in any other page 
or component using the same SessionState annotation and the same type. Does it 
need to be the same name
I'd say it doesn't, as I've not read otherwise.

My user contains lazy collections of other entities. Every page of my app 
contains the layout component which provides the login area and serves to 
create the session object for the app, retrieving the user entity in the 
process.
A page containing the layout component itself contains another component where 
these lazy collections are needed. The user logs in, the SessionState object is 
created, the user entity is stored inside the object. The page is requested 
again, and the component is initialized/rendered. The component contains a 
reference to the SessionState object. Inside the component, a tree should 
display objects of the lazy collection.
To do this, a service receives the user. The service tries to access the lazy 
collection, but fails with a
"failed to lazily initialize a collection of role:".

What I gather from this is, services don't operate within transactions?

UPDATE: I tried to access the lazy collection from the component itself, but 
the error was the same.
Even from the page, the error still was present.

This leads me to the point that I may be doing something wrong using an entity 
in a session storage?

Regards,
Daniel Poggenpohl

Reply via email to