Hi,
I have a Product entity which has (1 to Many) relationship to AddOnGroup entity. The AddOnGroup Entity has (Many to Many) relationship with AddOnProduct entity. When i try to add AddOnProduct into AddOnGroup entity. The AddOnProduct entity is not storing in the AddOnGroup association. I have attached the sample project for your reference.
Thanks for your response. When i change the AddOnGroup.addOnProducts to Owning side. Actually, now it does adds the AddOnProducts into AddOnGroup entity.
But i am getting the following error (AddOnGroup.addOnProducts is the owning side), when i try delete the Product Entity as shown below:
Right, because CASCADE is set for “FK constraint action” for AddOnGroup.product attribute which corresponds to the @OnDeleteInverse(DeletePolicy.CASCADE) annotation:
So Studio has generated a foreign key which tries to delete AddOnGroup record when corresponding Product is deleted. But reference from the join table between AddOnGroup and AddOnProduct prevents the deletion, because its FK has no CASCADE rule.
Perhaps you should add CASCADE rules to the join table. You can do it by adding the following Liquibase changelog:
After executing the changelog, Studio will generate another one that will again drop the FKs and recreate them without onDelete="CASCADE". You should “Remove and Ignore” all these changesets to get rid of them in the future: