Results 1 to 3 of 3

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

  1. #1
    Join Date
    Nov 2008
    Posts
    24

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    1,067

    Default

    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.
    Craig Walls
    Spring Social Project Lead

  3. #3
    Join Date
    Nov 2008
    Posts
    24

    Default

    Great, thanks for the clarification!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •