Skip to content

Latest commit

 

History

History

HibernateSpringBootCalculatePropertyGenerated

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

How To Calculate An Entity Property At INSERT Or UPDATE Time Via Hibernate @Generated

Description: This application is an example of calculating an entity property at INSERT or UPDATE time via Hibernate @Generated.

Key points:
- annotate the entity property that should be calculated with GenerationTime.ALWAYS or GenerationTime.INSERT
- if the database schema is generated via JPA annotations then use columnDefinition element of @Column (in production, you should not rely on this practice)
- in production, add the SQL query expression in CREATE TABLE (check, schema-sql.sql)