Skip to content

Commit cd042aa

Browse files
committed
加入学生测试类
1 parent cf5323f commit cd042aa

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

imoocSSHStudentManagementSystem/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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"/>

imoocSSHStudentManagementSystem/.settings/org.eclipse.wst.common.component

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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>

imoocSSHStudentManagementSystem/src/hibernate.cfg.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)