Refactor Lazy/Eager loading examples

This commit is contained in:
Grzegorz Piwowarek
2016-08-18 19:04:17 +02:00
parent b47d6543f2
commit 6973039ea9
9 changed files with 72 additions and 214 deletions
@@ -4,11 +4,10 @@ import static org.junit.Assert.*;
import java.util.Set;
import org.hibernate.Hibernate;
import org.junit.Before;
import org.junit.Test;
import com.baeldung.hibernate.fetching.model.OrderDetailEager;
import com.baeldung.hibernate.fetching.model.OrderDetailLazy;
import com.baeldung.hibernate.fetching.model.OrderDetail;
import com.baeldung.hibernate.fetching.view.FetchingAppView;
public class HibernateFetchingTest {
@@ -27,7 +26,7 @@ public class HibernateFetchingTest {
@Test
public void testLazyFetching() {
FetchingAppView fav = new FetchingAppView();
Set<OrderDetailLazy> orderDetalSetLazy = fav.lazyLoaded();
Set<OrderDetail> orderDetalSetLazy = fav.lazyLoaded();
assertFalse(Hibernate.isInitialized(orderDetalSetLazy));
}
@@ -12,7 +12,7 @@
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<mapping class="com.baeldung.hibernate.fetching.model.UserLazy" />
<mapping class="com.baeldung.hibernate.fetching.model.OrderDetailLazy" />
<mapping class="com.baeldung.hibernate.fetching.model.OrderDetail" />
</session-factory>
</hibernate-configuration>