File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed
imoocSSHStudentManagementSystem
test/com/southeast/iLoveMasami/entitytest Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<classpath >
33 <classpathentry kind =" src" path =" src" />
4+ <classpathentry kind =" src" path =" test" />
45 <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_121" >
56 <attributes >
67 <attribute name =" owner.project.facets" value =" java" />
Original file line number Diff line number Diff line change 22 <wb-module deploy-name =" imoocSSHStudentManagementSystem" >
33 <wb-resource deploy-path =" /" source-path =" /WebRoot" tag =" defaultRootSource" />
44 <wb-resource deploy-path =" /WEB-INF/classes" source-path =" /src" />
5+ <wb-resource deploy-path =" /WEB-INF/classes" source-path =" /test" />
56 <property name =" context-root" value =" imoocSSHStudentManagementSystem" />
67 <property name =" java-output-path" value =" /imoocSSHStudentManagementSystem/build/classes" />
78 </wb-module >
Original file line number Diff line number Diff line change 1414 <property name =" hibernate.hbm2ddl.auto" >update</property >
1515 <property name =" hibernate.current_session_context_class" >thread</property >
1616
17- <mapping resource =" entity/Students.hbm.xml" />
18- <mapping resource =" entity/Users.hbm.xml" />
17+ <mapping resource =" com/southeast/iLoveMasami/ entity/Students.hbm.xml" />
18+ <mapping resource =" com/southeast/iLoveMasami/ entity/Users.hbm.xml" />
1919 </session-factory >
2020</hibernate-configuration >
Original file line number Diff line number Diff line change 1+ package com .southeast .iLoveMasami .entitytest ;
2+
3+ import org .hibernate .Session ;
4+ import org .hibernate .SessionFactory ;
5+ import org .hibernate .cfg .Configuration ;
6+ import org .hibernate .service .ServiceRegistry ;
7+ import org .hibernate .service .ServiceRegistryBuilder ;
8+ import org .hibernate .tool .hbm2ddl .SchemaExport ;
9+ import org .junit .Test ;
10+
11+ public class TestStudents {
12+ @ Test
13+ public void testSchemaExport () {
14+ // 创建配置对象
15+ Configuration config = new Configuration ().configure ();
16+ // 创建服务注册对象
17+ ServiceRegistry serviceRegistry = new ServiceRegistryBuilder ().applySettings (config .getProperties ())
18+ .buildServiceRegistry ();
19+ // 创建sessionFactory
20+ SessionFactory sessionFactory = config .buildSessionFactory (serviceRegistry );
21+ //创建session对象
22+ Session session =sessionFactory .getCurrentSession ();
23+ //创建SchemaExport对象
24+ SchemaExport export =new SchemaExport (config );
25+ export .create (true , true );
26+
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments