Can a JPA entity have a field not mapped to a DB column

Viewed 10146

Is it possible for a JPA entity to have a field which is not mapped to any column in the data base table. Basically I need to store some additional data on my front end but I do not want to create an extra column in the table for this.

2 Answers

Just mark the field or getter with @javax.persistence.Transient annotation.

The data stored there will not be persisted, nor the ddl generator, if you use any, will pick that one up as an additional column of the table.

Marking @Transient annotation solve this problem but it will work after restart host server(application/web).

Related