01: package org.osbl.persistence.hibernate;
02:
03: import org.osbl.persistence.LoadCommand;
04: import org.osbl.persistence.GetCommand;
05: import org.hibernate.SessionFactory;
06: import org.hibernate.Session;
07:
08: public class HibernateGetCommand<T> extends GetCommand<T> implements
09: HibernateCommand {
10: SessionFactory sessionFactory;
11:
12: public void setSessionFactory(SessionFactory sessionFactory) {
13: this .sessionFactory = sessionFactory;
14: }
15:
16: public T execute() {
17: Session session = sessionFactory.getCurrentSession();
18: return (T) session.get(type, id);
19: }
20: }
|