// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package test.hibcrypt.common;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public abstract class BaseTest {
	protected abstract SessionFactory getSessionFactory();
	public void execute() {
	    SessionFactory sf = getSessionFactory();
	    Session s = sf.openSession();
	    Transaction tx = s.beginTransaction();
	    s.save(new Data(1, 123, "ABC"));
	    s.save(new Data(2, 456, "DEF"));
	    tx.commit();
        @SuppressWarnings("unchecked")
		List<Data> all = s.createQuery("SELECT d FROM Data AS d").list() ;
        for(Data d : all) {
            System.out.println(d.getIval() + " " + d.getSval());
        }
	    s.close();
	}
}
