Read Only Join

I have a transactional object associated with another object in which the related should not be updated in the case.

Eg. Case * → User

If the case belongs to the User, and vice versa, the User may have many related cases.

Association is mapped using OneToMany and JoinColumn JPA annotations.

I also tried marking the Trasactional annotation for the User object as readonly, and also made Transient fetch methods. But this does not stop the update for the user if his status has changed.

Please help me figure out a way to declare a read-only association for a user.

+3
source share
1 answer

yiu updatable=false @JoinColumn.

, setter user Case caseSet user. getter getCaseSet user :

public Set<Case> getCaseSet() {
    return Collections.unmodifiableSet(caseSet);
}
+1

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


All Articles