Pergunta

I've followed through this sample code and tried to implement it with only simple JPA. However, when I tried to sign up with a Google account or login with an existing user account, it gave me this error.

[RuntimeException: No EntityManager bound to this thread. Try to annotate your action method with @play.db.jpa.Transactional]

private static List<User> getAuthUserFind(final AuthUserIdentity identity) 
{
  -> List<User> query = JPA.em().createQuery(

After googling for a while, many solutions suggest adding the @Transactional annotation to the calling play action, but that action is in the play-authenticate code.

Is there a solution for this issue, or do I have to use it with Ebeans?

I am using Play Framework 2.2.1 and implementing my program in Java.

Foi útil?

Solução

It's not necessary to use Ebean, I have used mybatis as persistence provider, but in order to save the user and login without problem you should use the same hashing algorithm.

the hashing algorithm is used to store the password.

to use your custom persistence provider like JPA or whatever you want, you should implement the Authentication Provider interfaces, see UsernamePasswordAuthProvider in the example project for more details.

Focus ,especially, on "signupUser" and "loginUser" methods.

I have modified play-authenticate to support Login/password instead of email/password identityId.

see Modified version of Play-Authenticate.

Cheers.

Outras dicas

You could use JPA.withTransaction(callback). This is the better way when you can't put @Transactional in a method or you don't want to.

Cheers,

Alberto

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top