I am currently studying the Spring framework, mainly focusing on this security module. I looked at several guides in connection with registration and registration. I saw this common use of the transient or @Transient keyword in the password field in the User class .
My dummy application uses Spring Boot + Spring MVC + Spring Security + MySQL.
I know that
The Java transient keyword is used to indicate that the field should not be serialized.
JPA @Transient annotation ...
... indicates that the property or field is not constant . It is used to annotate a property or field of an entity class, a displayed superclass, or a nested class.
and org.springframework.data.annotation @Transient of annotation .. .
Marks the transition field for the display structure. Thus, the property will not be saved and will not be additionally checked by the display framework.
In my MySQL db, I have my spring_demo schema that has 3 tables:
+-----------------------+
| Tables_in_spring_demo |
+-----------------------+
| role |
| user |
| user_role |
+-----------------------+
When I use the transient keyword in the password field of the int class User password, it will not be stored in MySQL db. (example: test01)
mysql> select * from user;
+----+--------+------------------+----------+
| id | active | email | username |
+----+--------+------------------+----------+
| 1 | 1 | test01@gmail.com | test01 |
+----+--------+------------------+----------+
1 row in set (0,00 sec)
javax.persistence @Transient User, MySQL db. (: test02)
... org.springframework.data.annotation @Transient User, MySQL db. (: test03) ?
mysql> select * from user;
+----+--------+------------------+----------+--------------------------------------------------------------+
| id | active | email | username | password |
+----+--------+------------------+----------+--------------------------------------------------------------+
| 1 | 1 | test02@gmail.com | test02 | |
| 2 | 1 | test03@gmail.com | test03 | $2a$10$UbvmdhfcKxSNr/I4CjOLtOkKGX/j4/xQfFrv3FizxwEVk6D9sAoO |
+----+--------+------------------+----------+--------------------------------------------------------------+
2 rows in set (0,00 sec)
: @Transient spring.data, . ? @Transient ?
!