JPA。 @Column(更新= FALSE)上@ManyToOne相关领域 [英] JPA. @Column(updatable=false) on @ManyToOne related field
本文介绍了JPA。 @Column(更新= FALSE)上@ManyToOne相关领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的审计实体我有场 creationUser
,我想在分贝不更新合并
操作。
In my auditable entities I have field creationUser
which I would like to not update in db on merge
operation.
下面是我的实体code:
Here is my entity code:
@Column(updatable=false)
@ManyToOne(cascade = CascadeType.MERGE)
public User creationUser;
但它给我一个错误:
But it gives me an error:
Unexpected exception
PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory
Caused by: org.hibernate.AnnotationException: @Column(s) not allowed on a @ManyToOne property: models.AreaOfMedicine.creationUser
所以,我怎么能prevent从更新该领域?
请帮助
So how can I prevent from updating that field? Please help
推荐答案
使用 @JoinColumn(更新= FALSE)
而不是 @Column(更新= FALSE)
。
这篇关于JPA。 @Column(更新= FALSE)上@ManyToOne相关领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文