package database;

import java.util.Date;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 * CRUD Repository to manage entities.
 * 
 * @author Fernando Felix do Nascimento Junior
 *
 * @param <T>
 *            Entity model to manage
 */
public class Manager<T extends Model> {

	private Class<T> model;
	private Session session;

	public Manager(Class<T> model, Session session) {
		this.model = model;
		this.session = session;
	}

	public Long save(T o) {
		return (Long) session.save(o);
	}

	public void update(T o) {
		o.setDateUpdated(new Date());
		session.update(o);
	}

	public void saveOrUpdate(T o) {
		o.setDateUpdated(new Date());
		session.saveOrUpdate(o);
	}

	public Query createQuery(String query) {
		return session.createQuery(query);
	}

	public Criteria createQuery(Class<T> type) {
		return session.createCriteria(type);
	}

	public void delete(T o) {
		session.delete(o);
	}

	public T get(Long id) {
		return (T) session.get(model, id);
	}

	@SuppressWarnings("unchecked")
	public List<T> getAll() {
		return session.createCriteria(model).list();
	}

	public static <M extends Model> Manager<M> create(Class<M> o, Session session) {
		return new Manager<M>(o, session);
	}

}

@@ -849,27 +849,17 @@
 eate
-Query(Class%3CT%3E type
+Criteria(
 ) %7B%0A
@@ -894,12 +894,13 @@
 ria(
-type
+model
 );%0A%09
@@ -1084,32 +1084,24 @@
  %7B%0A%09%09return 
-session.
 createCriter
@@ -1103,21 +1103,16 @@
 riteria(
-model
 ).list()

Fix Manager#createCriteria