Pergunta

In Play 2.0m I have a static method in my model to wrap searching the DB:

public static User findUserByEmail(String email) {
    Finder<String, User> find = new Finder<String, User>(String.class, User.class);
    return find.where().eq("email", email).findUnique();
}

Is this threadsafe? I saw How Playframework 1.x static method works in a thread safe way but I don't know if that applies to the models too.

Foi útil?

Solução

Your method is thread-safe since you're only reading from the DB.
(and even if you were writing, I'm sure your DB can handle concurrent writes)

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