java - Spring Session User Info retrieval in Dao layer -


i have web-application in java, spring framework, hibernate on tomcat, has no security except login , logout functionality (no spring security)

i can access user information in controller by:

 // request httpservletrequest  httpsession session = request.getsession(true);  systemuser user = (systemuser) session.getattribute("user"); 

and logic. however, need information in dao layer. data database retrieve user specific data. 1 way pass "user" object service layer , service layer pass on dao layer. quite huge load of work.

i wonder if there way in spring how access session object in dao layer? or other way retrieve user specific data.

this might personal opinion far better passing type of information along method parameter rather accessing web context classes in dao.

what if want use dao classes outside of web application?

the dao accessing sort of request context holder makes question of data dao method needs run hidden secret - rather declaring method parameter data needs, accessing static method on class secretly.

this leads hard-to-test , hard-to-understand code.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -