How can I get the new jg_user's id?

  • sweet yonce

    sweet yonce - 2008-11-19

    Hi, Charles:
    thanks again for your help first.
    But I has a problem with jGuard, it is that how can I get the user ID in the "jg_user" table after I insert a new user by involed "am.createUser(st, stClone)" method, Becuase I want to get the new user ID to do some own business operation , I kown that we can select it with its "Login" credential, but I try to find a way to get it from involving the "am.createUser" method. 
    Can I get the user id by doing it?
    Thanks very much.

    • Vinicius Pitta Lima de Araujo

      Hi Yonce,
      I don't know what version you're using but according with the source code of HibernateAuthenticationManager, the user Id is stored as a private credential that can be get with the follow key "net.sf.jguard.ext.authentication.PersistedSubject.PERSISTENCE_ID". I think this fit your need.

      Hope it help.
      Vinícius Pitta Lima de Araújo

      • Vinicius Pitta Lima de Araujo

        Please, note that I am talking about a constant and not a string. The quotes can lead you in a misunderstood. :) The constant value is "persistenceId". But prefer to use the constant instead of the direct string.

        Vinícius Pitta Lima de Araújo

        • Charles Lescot

          Charles Lescot - 2009-02-06

          yes, Vini is right.
          htat's the way to do.




Log in to post a comment.