Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:03:29+00:00 2026-06-04T18:03:29+00:00

This is probably a newbie question. I have a table USER which contains info

  • 0

This is probably a newbie question.

I have a table USER which contains info about login, pass and authorities. Depending on authority or role, detail information about each user can be found in one of following: Teacher, Student, Parent. When the User logs in, the information stored in USER table can be easly taken from security context.

I want to display first name and last name all the time in the header after log in – these can be fetched from the other tables.

My question is this: how do I handle storing one of these objects in session all the time? Or is it okay just to store User (its stored by spring) and then fetch particular table every time I need detail information?

I use spring security 3, hibernate, jsp, sitemash.

For more clarification:

I know how to deal with logged user and to restrict some content. Login details (id, pass, role) are stored in USER table and this is ok – I can fetch it and show whereever I want. The problem is that the details about a particular user (address, name, email, etc) are stored in in another table (STUDENT, TEACHER, PARENT – depending on the role in USER table). This is what I want to know on every page – for example to show his/her name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:03:31+00:00Added an answer on June 4, 2026 at 6:03 pm

    TO cut it short –
    1. you need to extend spring User to provide additional fields.
    2. you need to implement UserDetailsService interface and reference it in the security context.
    3. Now you can fetch your object in a controller like this: authentication.getPrincipal() – rememebr to cast to your type.

    Additionaly – personally i always have AbstracController which is a base for every controller in my project. There, among others, I have method which returns current principal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably this is a newbie question :) But I have some Flash games built
This is probably a really newbie question (well, I'm pretty sure it is), but
I realize this is probably a hopelessly newbie question, but what is the difference
This is a very newbie question and i will probably get downvoted for it,
this must be a newbie question. I have this method in a controller: public
I'm a jstl newbie so probably this question will sound to you funny. Anyway,
This is probably a newbie question, but I can't seem to think of a
This is probably a newbie question, but is it possible to add a sprite
I know this is probably a newbie question, but is it possible to do
this is somewhat a newbie question probably. I'm generating keypairs with Java: KeyPairGenerator keyGen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.