3

I have been searching around for setting up referrential integrity for my database using Liferay IDE's service builder.

For e.g: I have a master table(entity) and a child table(entity). child table has a foreign key which is the primary key for the master table. If I delete one entry in the master table, the respective row in the child table should also get deleted. How can I achieve this in Liferay Service Builder.

Kiran Kulkarni
  • 1,434
  • 2
  • 18
  • 40

1 Answers1

0

You can't, Service Builder neither provides that nor is supposed to work with such database checks. In the Service Builder design, your services should delete dependent entities. In your example, the service which manages the master table should, on its delete method, delete also the child rows pointing to the deleting master row. A good example of this is the JournalArticleLocalServiceImpl.deleteArticle(JournalArticle, String, ServiceContext) method, which does, for example, this:

journalArticleImageLocalService.deleteImages(
    article.getGroupId(), articleId, article.getVersion());

// Expando

expandoRowLocalService.deleteRows(article.getId());
brandizzi
  • 26,083
  • 8
  • 103
  • 158