Reputation: 456
I've got the folowing problem. I write Regression-Tests against a databse. At the end i would clean up the created entities. Everything works except the deletion of one entity.
The error is:
View or function 'OrganizationUserView' is not updatable because the modification affects multiple base tables.
The JPA-Annotation is the following:
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "OrganizationUserView", joinColumns = {
@JoinColumn(name = "OrganizationID")},
inverseJoinColumns = {
@JoinColumn(name = "MemberID")}
)
private Set<Member> members = new HashSet<>();
The Organization and the Member-Objects are already deleted before.
Has anyone an idea how can i delete the Object?
Upvotes: 1
Views: 131
Reputation: 265
Create a separate entity representing the join table, mapped to the view, instead of using @JoinTable.
Discussed here (forum is dead so using archive.org): https://web.archive.org/web/20170113182538/https://forum.hibernate.org/viewtopic.php?f=1&t=985505&sid=dc550e634938fa271b76ecf60119d189
Upvotes: 1
Reputation: 456
For now, i've used a Database-Trigger
CREATE TRIGGER IO_Trig_DEL
ON [dbo].[OrganizationUserView]
INSTEAD OF DELETE
AS BEGIN
SET NOCOUNT ON;
END
GO
Upvotes: 1