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 7690265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:21:22+00:00 2026-05-31T20:21:22+00:00

I have a table of items, user should be able to choose some of

  • 0

I have a table of items, user should be able to choose some of them, then these items are put in the other table (in the second table they are associated with the user who chose the items). I could associate items and users with a help of usernames, but I suppose it wouldn’t be great. I wonder, what is a good way to do that. I know there is an easy way to retrieve the username (<sec:authentication property="principal.username"/>), but today I learnt there is no such a way for an id. What is a good way to solve this problem? Should I implement UserDetails to have an opportunity to get each id? Is there any good example of this implementation? I use Hibernate to communicate with the database. Is there any other way of the identification (compound key consisted of values that are easy to retrieve or something like that)? Thanks in advance.

  • 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-05-31T20:21:24+00:00Added an answer on May 31, 2026 at 8:21 pm

    Yes you have to implement your own UserDetail which will have an id attribute.

    You’ll then fill in this object during authentication in your implementation of UserDetailService.

    For example:

    @Service("CustomUserDetailService")
    public class CustomUserDetailService implements UserDetailsService{
    
        @Autowired
        private IUserDao userDao;
    
        @Override
        public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException, DataAccessException {
            User user = userDao.loadByName(name);
            CustomUserDetail customUserDetail = new CustomUserDetail();
            customUserDetail.setId(user.getId());
            customUserDetail.setPassword(user.getPassword());
            return customUserDetail ;
        }
    

    After that you can retrieve anything from your principal :

    <sec:authentication property="principal.id"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableViewController where the user should be able to edit the items.
I have a table with user items. Each user may have several types of
I have a following table using MVC that shows number of items the user
I have a table that keeps the user ratings for items. I want to
I have 3 tables: items , purchases , and collaborators . A user can
I have a table Users and a table Items In the Items table, I
I'm working on a very basic shopping cart system. I have a table items
I have a table of items. item has id, score 1, score 2. I
I have a table of items stored this way : A1 | B1 A1
I have two tables: Table items: | id | name | description | |

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.