@@ -0,0 +1,1271 @@
+package database;%0A%0Aimport java.util.Date;%0Aimport java.util.List;%0A%0Aimport org.hibernate.Criteria;%0Aimport org.hibernate.Query;%0Aimport org.hibernate.Session;%0A%0A/**%0A * CRUD Repository to manage entities.%0A * %0A * @author Fernando Felix do Nascimento Junior%0A *%0A * @param %3CT%3E%0A *            Entity model to manage%0A */%0Apublic class Manager%3CT extends Model%3E %7B%0A%0A%09private Class%3CT%3E model;%0A%09private Session session;%0A%0A%09public Manager(Class%3CT%3E model, Session session) %7B%0A%09%09this.model = model;%0A%09%09this.session = session;%0A%09%7D%0A%0A%09public Long save(T o) %7B%0A%09%09return (Long) session.save(o);%0A%09%7D%0A%0A%09public void update(T o) %7B%0A%09%09o.setDateUpdated(new Date());%0A%09%09session.update(o);%0A%09%7D%0A%0A%09public void saveOrUpdate(T o) %7B%0A%09%09o.setDateUpdated(new Date());%0A%09%09session.saveOrUpdate(o);%0A%09%7D%0A%0A%09public Query createQuery(String query) %7B%0A%09%09return session.createQuery(query);%0A%09%7D%0A%0A%09public Criteria createQuery(Class%3CT%3E type) %7B%0A%09%09return session.createCriteria(type);%0A%09%7D%0A%0A%09public void delete(T o) %7B%0A%09%09session.delete(o);%0A%09%7D%0A%0A%09public T get(Long id) %7B%0A%09%09return (T) session.get(model, id);%0A%09%7D%0A%0A%09@SuppressWarnings(%22unchecked%22)%0A%09public List%3CT%3E getAll() %7B%0A%09%09return session.createCriteria(model).list();%0A%09%7D%0A%0A%09public static %3CM extends Model%3E Manager%3CM%3E create(Class%3CM%3E o, Session session) %7B%0A%09%09return new Manager%3CM%3E(o, session);%0A%09%7D%0A%0A%7D%0A

Add fuc*ing nice Manager for entities.