forhas
forhas

Reputation: 12001

Not committing an hibernate entity field to the DB

I have a basic hibernate entity which contains a few fields. Currently all the fields are annotated with the @column annotation and the DB scheam corresponds accordingly.

Now, what I would like to do is to remove one of the fields from the DB but to keep it in the entity (it is only required for some validations, it should not be written to the DB).

So I have updated my DB scheam but what should I do with my entity? Should I simply remove the @column annotation from the field or is there a spesific jpa annotation that exclude the field from the crud operations?

Thanks in advance!

Upvotes: 1

Views: 250

Answers (1)

magomi
magomi

Reputation: 6685

Annotate the attribute in your entity class as @Transient and remove the @Column annotation.

Upvotes: 3

Related Questions