[BAEL-14841] - Fixed tests in hibernate-mapping, hibernate5, java-jpa modules

This commit is contained in:
amit2103
2019-05-30 01:33:20 +05:30
parent 6e4e729156
commit 9e470968e9
25 changed files with 165 additions and 95 deletions

View File

@@ -12,16 +12,12 @@ import java.net.URL;
import java.util.Properties;
public class HibernateUtil {
private static SessionFactory sessionFactory;
private HibernateUtil() {
}
public static SessionFactory getSessionFactory(Strategy strategy) {
if (sessionFactory == null) {
sessionFactory = buildSessionFactory(strategy);
}
return sessionFactory;
return buildSessionFactory(strategy);
}
private static SessionFactory buildSessionFactory(Strategy strategy) {

View File

@@ -2,12 +2,12 @@ package com.baeldung.hibernate;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public enum Strategy {
//See that the classes belongs to different packages
MAP_KEY_COLUMN_BASED(Collections.singletonList(com.baeldung.hibernate.persistmaps.mapkeycolumn.Order.class)),
MAP_KEY_COLUMN_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkeycolumn.Order.class,
com.baeldung.hibernate.basicannotation.Course.class)),
MAP_KEY_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkey.Item.class,
com.baeldung.hibernate.persistmaps.mapkey.Order.class,com.baeldung.hibernate.persistmaps.mapkey.User.class)),
MAP_KEY_JOIN_COLUMN_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Seller.class,

View File

@@ -1,18 +1,19 @@
package com.baeldung.hibernate.basicannotation;
import com.baeldung.hibernate.HibernateUtil;
import com.baeldung.hibernate.basicannotation.Course;
import com.baeldung.hibernate.Strategy;
import org.hibernate.PropertyValueException;
import java.io.IOException;
import javax.persistence.PersistenceException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.SessionFactory;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import com.baeldung.hibernate.HibernateUtil;
import com.baeldung.hibernate.Strategy;
public class BasicAnnotationIntegrationTest {
@@ -48,7 +49,7 @@ public class BasicAnnotationIntegrationTest {
}
@Test(expected = PropertyValueException.class)
@Test(expected = PersistenceException.class)
public void givenACourse_whenCourseNameAbsent_shouldFail() {
Course course = new Course();