Spring Data JPA - how to set transient fields after retrieval

前端 未结 3 901
遇见更好的自我
遇见更好的自我 2021-01-22 16:41

After an entity is fetched using the JpaRepository methods of Spring Data JPA, e.g. findOne, findBy..., etc., I was wondering what would b

3条回答
  •  长发绾君心
    2021-01-22 17:26

    Have not tried myself but it seems that the @PostLoad annotation may help you to execute code to change the state of a business object after retrieving it from the database.

    But in your concrete case I would simply create a method getFullName that concatenates firstName and secondName without storing the value in the bean.

提交回复
热议问题