KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > hibernate > HibernateSessionImpl


1 package com.opensymphony.webwork.hibernate;
2
3 import com.opensymphony.xwork.interceptor.component.Disposable;
4 import com.opensymphony.xwork.interceptor.component.Initializable;
5 import org.hibernate.Session;
6
7 import java.util.List JavaDoc;
8
9 /**
10  * User: plightbo
11  * Date: Aug 10, 2005
12  * Time: 12:06:19 AM
13  */

14 public class HibernateSessionImpl implements HibernateSession, HibernateConfigurationAware, Initializable, Disposable {
15     HibernateConfiguration config;
16     Session session;
17
18     public void setHibernateConfiguration(HibernateConfiguration config) {
19         this.config = config;
20     }
21
22     public void init() {
23         session = config.getSessionFactory().openSession();
24     }
25
26     public void dispose() {
27         session.flush();
28         session.close();
29     }
30
31     public List JavaDoc getAll(Class JavaDoc type) {
32         return session.createCriteria(type).list();
33     }
34
35     public void create(Object JavaDoc o) {
36         session.save(o);
37     }
38 }
39
Popular Tags