首页 > 代码库 > Hibernate!!关于关系映射的测试代码

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     //@BeforeClass16     public  static  void  beforeClass(){17         sessionFactory  = new  AnnotationConfiguration().configure().buildSessionFactory();18     }19     20 //    @AfterClass21     public  static  void  afterClass(){22         sessionFactory.close();23     }24     25     26 27     @Test28     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!!关于关系映射的测试代码