-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenSessionInViewFilter.java
More file actions
45 lines (30 loc) · 936 Bytes
/
OpenSessionInViewFilter.java
File metadata and controls
45 lines (30 loc) · 936 Bytes
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
package filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.hibernate.Session;
import utils.HibernateUtils;
public class OpenSessionInViewFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(
ServletRequest arg0,
ServletResponse arg1,
FilterChain chain)
throws IOException, ServletException {
Session session = HibernateUtils.getSession();
try {
chain.doFilter(arg0, arg1);
} finally {
HibernateUtils.closeSession(session);
}
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}