title: @Transient annotation, @org.springframework.data.annotation.Transient annotation, transient keyword and password storing
body: <p>Currently I'm learning the Spring framework, mainly focusing on it's Security Module. I've watched some guides in connection with registration and login. I saw this common usage of <strong>transient</strong> keyword or <strong>@Transient</strong> annotation on the password field in the <strong>User</strong> class. </p>
  
  <p>My dummy app is using Spring Boot + Spring MVC + Spring Security + MySQL.</p>
  
  <p>I know that </p>
  
  <blockquote>
    <p>Java's <strong>transient</strong> keyword is used to denote that a field is not to be serialized.</p>
  </blockquote>
  
  <p>JPA's <strong>@Transient annotation</strong>...</p>
  
  <blockquote>
    <p>...specifies that the property or <strong>field is not persistent</strong>. It is used to annotate a property or field of an entity class, mapped superclass, or embeddable class.</p>
  </blockquote>
  
  <p>and the org.springframework.data.annotation's <strong>@Transient annotation..</strong>.</p>
  
  <blockquote>
    <p>Marks a field to be transient for the mapping framework. Thus the <strong>property will not be persisted</strong> and not further inspected by the mapping framework.</p>
  </blockquote>
  
  <p>In my MySQL db I have my spring_demo schema which has 3 tables: </p>
  
  <pre><code>+-----------------------+
  | Tables_in_spring_demo |
  +-----------------------+
  | role                  |
  | user                  |
  | user_role             |
  +-----------------------+
  </code></pre>
  
  <p>When I'm using the <strong>transient</strong> keyword on the password field int the User class, it would not be stored in the MySQL db. (example: test01)</p>
  
  <pre><code>mysql&gt; select * from user;
  +----+--------+------------------+----------+
  | id | active | email            | username |
  +----+--------+------------------+----------+
  |  1 |      1 | test01@gmail.com | test01   |
  +----+--------+------------------+----------+
  1 row in set (0,00 sec)
  </code></pre>
  
  <p>When I'm using the <strong>javax.persistence @Transient</strong> annotation on the password field in the User class, it also would not be stored in the MySQL db. (example: test02)</p>
  
  <p>But... when I'm using the <strong>org.springframework.data.annotation @Transient</strong> annotation on the password field in the User class it does stored in the MySQL db. (example: test03) <strong>Why is that?</strong></p>
  
  <pre><code>mysql&gt; 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)
  </code></pre>
  
  <p><strong>My main questions are, when I'm using the spring.data based @Transient annotation the password field has persisted. Why? And why should I use any @Transient annotation on a password field?</strong></p>
  
  <p>Thank you for your guidance and help in advance!    </p>