Hibernate: Have a field that is not-peristed but can be pulled from DB?

I am the following Hibernate Entity:

@Entity(name = "status")
@Table(name = "status")
public class Status implements Serializable {

    @Column(name = "status_id")
    private Integer statusId;

    @Column(name = "status_label")
    private String statusLabel;

    private String statusOrigin;


statusOrigin is transient as it is not a column in the status table.

This works fine for creating the object with only statusId and statusLabel fields as expected.

However when I want to return the Status object to the front end with a join query which populates all 3 fields it does not work as statusOrigin is transient.

How can I do the following:

  1. keep the create functionality as it is
  2. Ensure that statusOrigin field is populated from the results of the join query and sent to UI


You can add insertable and updatable false to the field


Leave a Reply

Your email address will not be published. Required fields are marked *