Announcement Announcement Module
No announcement yet.
Local "userId": an id (numerical) or username? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Local "userId": an id (numerical) or username?

    Hello all,

    I am embarking on integrating Spring Social into some projects and I have one quick newbie question. Sorry if this has been asked already. I searched the forums a bit and couldn't find a similar question being answered.

    In my apps I generally have a User class, with an id (the numerical primary key) and a username, among other fields. One thing that is not clear to me from the Spring Social docs, code, and JavaDoc is whether the Spring Social "userId" (e.g. the argument in UsersConnectionRepository.createConnectionReposito ry()) is intended to be the local user's username or their numerical pk id. First point of confusion for me is that it's a String. That makes me think maybe I'm supposed to use the local username for the Spring Social "userId"...? Or maybe just the toString() of the local user id?

  • #2
    The user ID can be any ID you choose that uniquely identifies the local user; either a stringified primary key or the username will work, so long as you know that it uniquely identifies the user.

    The reason it is a String is for flexibility with applications that don't use a numeric ID for users. You can always stringify a number, but you can't necessarily go the other way.


    • #3
      Great, thanks for the clarification!