Languages
[Edit]
EN

Spring JPA - ignore entity field with @Transient

8 points
Created by:
Burhan-Boyce
298

In this short article, we would like to show how to ignore some entiy fields in Spring JPA.

Quick solution (use @Transient annotation):

package com.example;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "users")
public class UserEntiy {

    // some fields here ...    

    @Transient
    String ignoredField;

    // some fields here ...   
}

Note: @Transient causes the field is not mapped by Hibernate (will be not serialized by Jackson too). 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join