Usage of the Hibernate @LazyCollection Annotation Article by Abdallah Sawan
This commit is contained in:
parent
342730c4a9
commit
927b10e02e
|
@ -1,9 +1,14 @@
|
|||
package com.baeldung.hibernate.lazyCollection.model;
|
||||
package com.baeldung.hibernate.lazycollection.model;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Entity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
package com.baeldung.hibernate.lazyCollection.model;
|
||||
package com.baeldung.hibernate.lazycollection.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Employee {
|
|
@ -1,7 +1,7 @@
|
|||
package com.baeldung.hibernate.lazyCollection;
|
||||
package com.baeldung.hibernate.lazycollection;
|
||||
|
||||
import com.baeldung.hibernate.lazyCollection.model.Branch;
|
||||
import com.baeldung.hibernate.lazyCollection.model.Employee;
|
||||
import com.baeldung.hibernate.lazycollection.model.Branch;
|
||||
import com.baeldung.hibernate.lazycollection.model.Employee;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
@ -29,12 +29,13 @@ public class LazyCollectionIntegrationTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTests() {
|
||||
Configuration configuration = new Configuration().addAnnotatedClass(Branch.class).addAnnotatedClass(Employee.class)
|
||||
.setProperty("hibernate.dialect", H2Dialect.class.getName())
|
||||
Configuration configuration = new Configuration().addAnnotatedClass(Branch.class)
|
||||
.addAnnotatedClass(Employee.class).setProperty("hibernate.dialect", H2Dialect.class.getName())
|
||||
.setProperty("hibernate.connection.driver_class", org.h2.Driver.class.getName())
|
||||
.setProperty("hibernate.connection.url", "jdbc:h2:mem:test")
|
||||
.setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "")
|
||||
.setProperty("hibernate.hbm2ddl.auto", "update");
|
||||
|
||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
||||
.applySettings(configuration.getProperties()).build();
|
||||
|
Loading…
Reference in New Issue