-
Notifications
You must be signed in to change notification settings - Fork 1k
create resol #1075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
create resol #1075
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Hey there! 👋 Thanks for submitting your code. It looks like you've done a great job overall! There are just a couple of things we need to address before we can approve this PR:
- In
src/main/java/mate/academy/hibernate/relations/dao/impl/MovieDaoImpl.java
, the exception message in theadd
method is incorrect. It currently says "Can not save country to DB" but it should be "Can not save movie to DB". - In
src/main/java/mate/academy/hibernate/relations/util/HibernateUtil.java
, please add a private default constructor to theHibernateUtil
class. This will prevent the creation ofHibernateUtil
objects, as required by the checklist.
Once these minor issues are resolved, I'll be happy to approve this PR. Keep up the great work! 👍
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review
button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor
tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
import mate.academy.hibernate.relations.dao.impl.ActorDaoImpl; | ||
import mate.academy.hibernate.relations.dao.impl.CountryDaoImpl; | ||
import mate.academy.hibernate.relations.dao.impl.MovieDaoImpl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good to see the imports for the DAO implementations. Ensure that these implementations correctly handle database interactions for their respective entities.
import mate.academy.hibernate.relations.service.impl.ActorServiceImpl; | ||
import mate.academy.hibernate.relations.service.impl.CountryServiceImpl; | ||
import mate.academy.hibernate.relations.service.impl.MovieServiceImpl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job importing the service implementations! Make sure these implementations are correctly utilizing the DAOs to perform operations on the entities.
import mate.academy.hibernate.relations.util.HibernateUtil; | ||
import org.hibernate.SessionFactory; | ||
|
||
public class Main { | ||
private static final String COUNTRY = "USA"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting these constants into a configuration file or using environment variables for better maintainability and to avoid hardcoding values. However, it's not required by the task description.
import mate.academy.hibernate.relations.util.HibernateUtil; | ||
import org.hibernate.SessionFactory; | ||
|
||
public class Main { | ||
private static final String COUNTRY = "USA"; | ||
private static final String ACTOR = "Vin Diesel"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting these constants into a configuration file or using environment variables for better maintainability and to avoid hardcoding values. However, it's not required by the task description.
import mate.academy.hibernate.relations.util.HibernateUtil; | ||
import org.hibernate.SessionFactory; | ||
|
||
public class Main { | ||
private static final String COUNTRY = "USA"; | ||
private static final String ACTOR = "Vin Diesel"; | ||
private static final String MOVIE = "Fast and Furious"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting these constants into a configuration file or using environment variables for better maintainability and to avoid hardcoding values. However, it's not required by the task description.
fastAndFurious.setActors(List.of(vinDiesel)); | ||
MovieService movieService = null; // TODO: initialize this instance | ||
MovieService movieService = new MovieServiceImpl(new MovieDaoImpl(sessionFactory)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good to see the service being instantiated with the DAO implementation. Ensure the MovieServiceImpl
correctly implements the MovieService
interface.
fastAndFurious.setActors(List.of(vinDiesel)); | ||
MovieService movieService = null; // TODO: initialize this instance | ||
MovieService movieService = new MovieServiceImpl(new MovieDaoImpl(sessionFactory)); | ||
movieService.add(fastAndFurious); | ||
System.out.println(movieService.get(fastAndFurious.getId())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line retrieves and prints the movie. Verify that the get
method in MovieService
and MovieDao
correctly retrieves the movie along with its associated actors. Also, confirm that the toString()
method in the Movie
class includes the actors' information.
if (transaction != null) { | ||
transaction.rollback(); | ||
} | ||
throw new DataProcessingException("Can not save country to DB"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception message is related to saving a 'country', but it should be related to saving a 'movie'. Change the message to Can not save movie to DB
.
@@ -54,7 +73,7 @@ public String toString() { | |||
return "Actor{" | |||
+ "id=" + id | |||
+ ", name='" + name + '\'' | |||
+ ", country='" + country + '\'' | |||
+ ", country=" + country |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good to see that the toString()
method includes the country information. This will be helpful for debugging and logging.
public class HibernateUtil { | ||
private static final SessionFactory sessionFactory = initSessionFactory(); | ||
|
||
private static SessionFactory initSessionFactory() { | ||
return new Configuration().configure().buildSessionFactory(); | ||
} | ||
|
||
public static SessionFactory getSessionFactory() { | ||
return null; | ||
return sessionFactory; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the checklist, you should add a private default constructor to the HibernateUtil
class to prevent creating instances of this class.
public class HibernateUtil {
private static final SessionFactory sessionFactory = initSessionFactory();
private HibernateUtil() {
// Private constructor to prevent instantiation
}
private static SessionFactory initSessionFactory() {
return new Configuration().configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Great job! 🎉 All the code looks good and follows the instructions, including the important fixes for the exception message and the HibernateUtil
class. Keep up the excellent work! 👍
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.