java - Create a custom JPA temporal annotation -


I want some mycoulmns in the JPA unit so that I take the value from the database during the inserts / updates, i.e. from Oracle sys_context, trust me Is the temporary annotation of JPA's included / timestamps generated during the updating / updating, is there any way that I can make a custom annotation somewhat current or provide some default values ​​during the insert / update, If you can face this situation then nobody can give a hint.

I assume some code in the JPA unit from the database during the inserts / updates

Configure @ column to be inaccessible and not be editable, and annotate fields (specific comment with Hibernate). By doing this, Hibernate will receive value from the database after an inserted, updated reference document:

Add some properties generated from your database or at the update time Are there. Being in hibernation can deal with such properties and then to trigger these selections to read these properties.

  @ Entity public class antenna {@Id Public Integer ID; @ Generated (Generation Time. Alway) @column (insertable = false, updateable = false) public string longitude; @ Generated (GenerationTime.INSERT) @column (insertable = false) public string latitude; }  

Comment your property as a @generated , to ensure that your entry or updating ability is conflicts with the generation strategy you have selected Does not. When the GenerationTime.INSERT is selected, then there should be no attributable columns, when the GenerationTime.ALWAYS is selected, the inclusionable and neither the updated columns are included. should be there.

@Version properties can not be made with the @Generated (INSERT) design, it's either ever or Always .


Comments