Creating Custom JPA Temporary Annotations

I want some of mycoulmns in the JPA entity to accept values ​​from the database during insertions / updates, i.e. from Oracle sys_context, I believe that the JPA timeline annotation includes timestamps created using the database during insertion / update . Is there a way to create a custom annotation a bit like this or provides some default values ​​during insertions / updates, can someone give some pointers if you come across this situation.

+3
source share
1 answer

, mycoulmns JPA /

@Column, , @Generated ( Hibernate). , Hibernate , . :

2.4.3.5.

. , .

@Entity
public class Antenna {
    @Id public Integer id;
    @Generated(GenerationTime.ALWAYS) 
    @Column(insertable = false, updatable = false)
    public String longitude;

    @Generated(GenerationTime.INSERT) @Column(insertable = false)
    public String latitude;
}

@Generated , . GenerationTime.INSERT, , GenerationTime.ALWAYS, .

@Version @Generated(INSERT) , NEVER ALWAYS.

+2

Source: https://habr.com/ru/post/1755202/


All Articles