Hibernate!!关于关系映射的测试代码

 1 package com.hb.model;

 2 

 3 import static org.junit.Assert.*;

 4 

 5 import org.hibernate.SessionFactory;

 6 import org.hibernate.cfg.AnnotationConfiguration;

 7 import org.hibernate.tool.hbm2ddl.SchemaExport;

 8 import org.junit.AfterClass;

 9 import org.junit.BeforeClass;

10 import org.junit.Test;

11 

12 public class ORMMappingTest {

13     private  static  SessionFactory   sessionFactory ; 

14     

15     //@BeforeClass

16     public  static  void  beforeClass(){

17         sessionFactory  = new  AnnotationConfiguration().configure().buildSessionFactory();

18     }

19     

20 //    @AfterClass

21     public  static  void  afterClass(){

22         sessionFactory.close();

23     }

24     

25     

26 

27     @Test

28     public void test() {

29         new SchemaExport(new  AnnotationConfiguration().configure()).create(true, true);

30     }

31     

32     public static void main(String[] args) {

33         beforeClass();

34     }

35 

36 }

 

你可能感兴趣的:(Hibernate)