Created
July 5, 2015 00:25
-
-
Save yogonza524/74025bf50b250be78489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @Owner Gonzalo H. Mendoza | |
* @Version 1.0.0 | |
*/ | |
import java.util.List; | |
import org.blh.habilitacion.util.HibernateUtil; | |
import org.hibernate.Session; | |
import org.hibernate.SessionFactory; | |
/** | |
* | |
* @author Gonza | |
*/ | |
public abstract class AbstractController<T> { | |
protected static SessionFactory sf; | |
protected boolean composite = false; | |
public List<T> all(){ | |
sf = HibernateUtil.getSessionFactory(); | |
Session s = sf.openSession(); | |
List<T> l = s.createCriteria(className()).list(); | |
beforeAll(); | |
if(composite){ | |
for(T o : l){ | |
initialize(o); | |
} | |
} | |
s.close(); | |
afterAll(); | |
return l; | |
} | |
public abstract Class<T> className(); | |
public abstract void initialize(T entity); | |
public void beforeAll(){} | |
public void afterAll(){} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment