-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddDateSource.java
More file actions
56 lines (48 loc) · 1.24 KB
/
AddDateSource.java
File metadata and controls
56 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;
import com.nxdcms.entity.Student;
import utils.HibernateUtils;
public class AddDateSource {
@Test
public void testInsert(){
Session session = null;
Transaction tx = null;
try {
session = HibernateUtils.getSession();
tx = session.beginTransaction();
Student stu = null;
int id = 14550000;
for(int i=0;i<2000;i++){
stu = new Student();
id = 14550000+i;
stu.setStudentId(Integer.toString(id));
stu.setStudentCollege("信息工程学院");
stu.setStudentAge(19);
stu.setStudentClass("软件工程"+i%6+"班");
stu.setStudentName("张三");
//?
stu.setStudentIdcard("xxxxxxxxxxxx");
stu.setStudentPassword("123456");
stu.setStudentPhone("1381236124"+i%10);
stu.setStudentStartYear("12312");
//?
stu.setStudentDiscipline("yyyyyyyyyy");
stu.setStudentEmail("[email protected]");
session.save(stu);
if(i%100==0){
session.flush();
session.clear();
}
}
tx.commit();
} catch (Exception e) {
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
}
HibernateUtils.closeSession(session);
}
}