View Javadoc
1   package ejava.jpa.examples.tuning.env;
2   
3   import javax.persistence.EntityManager;
4   
5   import org.junit.AfterClass;
6   import org.junit.BeforeClass;
7   import ejava.jpa.examples.tuning.MovieFactory;
8   import ejava.jpa.examples.tuning.TestBase;
9   import ejava.jpa.examples.tuning.TestLabel;
10  import ejava.jpa.examples.tuning.MovieFactory.SQLConstruct;
11  import ejava.jpa.examples.tuning.benchmarks.LoopQuery;
12  
13  /**
14   * This environment sets up the object model with all fetch=LAZY relationships.
15   */
16  @TestLabel(label="Loop Lazy")
17  public class LoopLazy extends LoopQuery {
18  	private static String originalPU;
19  	
20  	@AfterClass
21  	public static void tearDownBenchmarkClass() {
22  	    PERSISTENCE_UNIT = originalPU;
23  	}
24  
25  	@BeforeClass
26  	public static void setUpEnv() {
27  		TestBase.tearDownBaseClass();
28  		originalPU = PERSISTENCE_UNIT;
29  	    PERSISTENCE_UNIT = "movietune-test-thin";
30          getDAO();
31  		TestBase.tearDownBaseClass();
32  
33  		EntityManager em=getEMF().createEntityManager();
34  		MovieFactory mf = new MovieFactory().setEntityManager(em);
35  		SQLConstruct[] constructs = new SQLConstruct[]{
36  				mf.MOVIE_ROLE_ACTOR_MOVIE_CDX,
37  				mf.MOVIE_ROLE_MOVIE_ACTOR_CDX
38  		};
39  		mf.executeSQL(constructs).assertConstructs(constructs).flush();
40  		
41  		em.close();
42  	}
43  }