Hibernate 5 Transient variable not populating

428 views Asked by At

I have an User pojo class, when I am using Hibernate 4.2.0 Final version, transient member populating to the object while serialization but its not populating while using Hibernate 5.0.3.Final version.

What configuration required in Hibernate 5 version to make the transient member appear in the criteria object/serialization?

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity(name = "el_users")
@Table(name = "el_users")
public class User{

    public User() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column
    private Long id;

    @Column(name = "username")
    @Size(min = 2, max = 30, message = "Please enter username")
    private String username;

    @Column(name = "password")
    @NotNull
    @Size(min = 2, max = 40, message = "Please enter password")
    private String password;

    @Column(name = "first_name")
    @Size(min = 2, max = 40, message = "Please enter first name")
    private String first_name;

    @Column(name = "last_name")
    private String last_name;

    @Column(name = "email")
    @Size(min = 2, max = 50, message = "Please enter email")
    private String email;

    @Column(name = "access_group")
    private String accessGroup;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirst_name() {
        return first_name;
    }

    public void setFirst_name(String first_name) {
        this.first_name = first_name;
    }

    public String getLast_name() {
        return last_name;
    }

    public void setLast_name(String last_name) {
        this.last_name = last_name;
    }

    public String getAccessGroup() {
        return accessGroup;
    }

    public void setAccessGroup(String accessGroup) {
        this.accessGroup = accessGroup;
    }

    @Transient
    public String getFullName() {
        return first_name + " " + (last_name != null ? last_name : "");
    }

    public Long getId() {
        return id;
    }

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

} 

Hibernate 4.2.0.Final Hibernate 4.2.0.Final Hibernate 5.0.3.Final Hibernate 5.0.3.Final

0

There are 0 answers