0

i have a User entity with a password property. I want to store bcrypt hashed passwords in the database.

How can i handle the hashing as transparent as possible with jpa/eclipselink.

I want the hashing to take plase as late as possible and for the code that accesses the user to know as few as possible about the underlying hash mechanism (or its existence).

Currently i only access the password in jpql queries and the user doesn't even have a getPassword() method.

Greetings, Laures

4

1 回答 1

0

You can have different access methods; one set for the user and another for the JPA provider that handle the data underneath as required. The access methods required by the provider must deal with the data as it is needed to persist in the database. When using property access, just mark the get/set methods you want the provider to use with the mapping annotations, and either use different naming for user methods or mark them as transient. You are then free to store the data in the User entity how ever is needed.

于 2012-08-28T13:29:01.847 回答