docs: update metadata mapping

This commit is contained in:
Ilkka Seppälä
2024-05-08 10:26:37 +03:00
parent 1b04adadb8
commit 2faa45aa80
5 changed files with 39 additions and 24 deletions
@@ -56,9 +56,8 @@ public class App {
* Program entry point.
*
* @param args command line args.
* @throws Exception if any error occurs.
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
// get service
var userService = new UserService();
// use create service to add users
@@ -49,8 +49,8 @@ public class UserService {
try (var session = factory.openSession()) {
var tx = session.beginTransaction();
List<User> userIter = session.createQuery("FROM User").list();
for (var iterator = userIter.iterator(); iterator.hasNext();) {
users.add(iterator.next());
for (User user : userIter) {
users.add(user);
}
tx.commit();
} catch (HibernateException e) {
@@ -24,6 +24,7 @@
*/
package com.iluwatar.metamapping.utils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
@@ -34,6 +35,7 @@ import org.hibernate.cfg.Configuration;
@Slf4j
public class HibernateUtil {
@Getter
private static final SessionFactory sessionFactory = buildSessionFactory();
/**
@@ -50,14 +52,6 @@ public class HibernateUtil {
return new Configuration().configure().buildSessionFactory();
}
/**
* Get session factory.
* @return session factory
*/
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
/**
* Close session factory.
*/
@@ -33,7 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
*
* Solution: Inserted assertion to check whether the execution of the main method in {@link App#main(String[])}
* throws an exception.
*/