Skip Hibernate mapping in Spring using Transient annotation

@Transient to not save a field with Hibernate in Spring

Transient is an hibernate state where we ask hibernate to not persist and save a field into the database because it's a temporary field used for some manipulation or whatever goal you have. So by adding the @Tansient annotation, hibernate will skip mapping that particular entity class variable.

package com.yamicode.snippet.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;

@Entity
public class YamiCode {
    
    @GeneratedValue
    @Id
    private long id;
    
    @Transient
    private String notPersisted;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getNotPersisted() {
        return notPersisted;
    }

    public void setNotPersisted(String notPersisted) {
        this.notPersisted = notPersisted;
    }
}