Newer
Older
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.Service;
import com.Domain.Context;
import com.Domain.User;
import com.Mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* cglib 代理 Created by lqt
*/
@Service
public class UserService {
@Autowired
private UserMapper userMapper;
// 脏读
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
public void insert() {
User user = new User();
user.setUsername("hch");
user.setPassword("123");
user.setEnabled(true);
Context build = new Context();
build.setUsername("hcj");
build.setPassword("123");
build.setContext("hello world");
build.setEnabled(true);
user.setContext(build);
userMapper.insert(user);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
throw new RuntimeException();
}
public void insertUser(User user) {
user.setEnabled(true);
Context build = new Context();
build.setUsername("hcj");
build.setPassword("123");
build.setContext("hello world");
build.setEnabled(true);
user.setContext(build);
user.setContext(build);
userMapper.insert(user);
}
// @Transactional(readOnly = true)
public List<User> findUser() {
return userMapper.selectAll();
}
public User selectUser(String username, String password) {
return userMapper.selectUser(username, password);
}
public List<User> selectUserByUsername(String username) {
return userMapper.selectUserByUsername(username);
}
public void insertUserNoObject(User user) {
user.setEnabled(true);
userMapper.insert(user);
}
}