EN
Spring JPA - ignore entity field with @Transient
8 points
In this short article, we would like to show how to ignore some entiy fields in Spring JPA.
Quick solution:
Use
@Transient
annotation.
Practical example:
xxxxxxxxxx
1
package com.example;
2
3
import javax.persistence.Entity;
4
import javax.persistence.Table;
5
import javax.persistence.Transient;
6
7
8
name = "users") (
9
public class UserEntiy {
10
11
// some fields here ...
12
13
14
private String ignoredField;
15
16
// some fields here ...
17
}
Note:
@Transient
causes the field is not mapped by Hibernate (will be not serialized by Jackson too).