Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your tasks Complete the database model that will be used for storing articles. Articles must be stored in table article, with its tags in a
Your tasks Complete the database model that will be used for storing articles. Articles must be stored in table article, with its tags in a table named tag. Register ArticleService as a Spring Bean. Use ArticleRepository as Spring Data JPA repository and inject it into ArticleService. 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 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 you should throw a RuntimeException with message "Article not found". Implement a delete method that allows an article to be deleted. Add validation to the create and update methods check whether
Your tasks
Complete the database model that will be used for storing articles.
Articles must be stored in table article, with its tags in a table
named tag.
Register ArticleService as a Spring Bean.
Use ArticleRepository as Spring Data JPA repository and inject it into
ArticleService.
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 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 you should throw a
RuntimeException with message "Article not found".
Implement a delete method that allows an article to be deleted.
Add validation to the create and update methods check whether
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started