Skip to content

Commit

Permalink
Help me with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkostanetskyi committed Aug 26, 2024
1 parent 23c1024 commit 53017c5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Binary file modified mem.lck
Binary file not shown.
3 changes: 2 additions & 1 deletion src/main/java/mate/academy/dao/MovieDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public Movie add(Movie movie) {
transaction = session.beginTransaction();
session.persist(movie);
transaction.commit();
} catch (DataProcessingException e) {
} catch (Exception e) {
if (transaction != null) {
transaction.rollback();
}
throw new DataProcessingException("error while adding movie", e);
} finally {
if (session != null) {
session.close();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/mate/academy/util/HibernateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
public class HibernateUtil {
private static final SessionFactory sessionFactory = initSessionFactory();

private HibernateUtil() {

}

private static SessionFactory initSessionFactory() {
return new Configuration().configure().buildSessionFactory();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test?serverTimezone=UTC</property>
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="connection.username">root</property>
Expand Down

0 comments on commit 53017c5

Please sign in to comment.