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 ; 8 9 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 getAll(Class type) { 32 return session.createCriteria(type).list(); 33 } 34 35 public void create(Object o) { 36 session.save(o); 37 } 38 } 39 | Popular Tags |