Question: You are given a spring boot application ( version 2 . 0 . 5 ) with spring - boot - starter - dara - jpa

You are given a spring boot application ( version 2.0.5) with spring-boot-starter-dara-jpa and lombok dependencies. Database access js fully configured ( h2 database is used ).The application is compiled using JDK. ArticleDTO as used the code is defined as follows :
Class ArticleDTO{
Private string title;
Private String content;
Private List tags;
}
Your tasks
1. Complete the database model that will be used for storing articles.
2. articles must be stored in table article, with its tags in a table named tag.
3.Register ArticleService as a Spring Bean.
4.Use ArticleRepository as Spring data jpa repository and inject it into article service.
5.Configure the Article class as a Hibernate entity. It should correspond to the article table in the database.
Implement a findById method- it should return the article with the given id if it exists in the database, or return an empty article otherwise
Implement a findbytitle method - it should return list of articles with the title containing given argument
Implement a create method- it should insert an article into the database and return its generated id.
Implement an update method that should update an existing article. If there is no article with the given id, should throw a runtime exception with message "Article not found".
Implement a delete method that allows an article to be deleted.
Add validations to the create and update method.Check whether content doesn't contain any words defined in the blacklist. The blacklist is defined as a configuration property articles. Blacklist which contains comma separated words like banned_word1, banned_word2. if validation fails throw a Runtimeexception with message Article content contains forbidden words. A check based in simple string.contains is good enough - you dont have to worry about case sensitivity spaces etc.
Remarks
All values in input DTO are not null. You dont have to check this.
If your code needs to be executed in transition you have to start the transaction by yourself.
If you have time create new source files with java classes, please remember to put them in package com.codility.tasks.hibernate.curd.solution
Also you cant rename the existing classes.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!