package esimene; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class Test4 { public static void main(String[] kapsas) { Configuration c = new Configuration().configure(); SessionFactory sf = c.buildSessionFactory(); Session s = sf.openSession(); Transaction tx = s.beginTransaction(); try { Kassid k=new Kassid(); k.setKassinimi("Ants"); k.setSynniaasta(1938); s.save(k); tx.commit(); } catch (Exception e) { System.out.println(e.getMessage().toString()); tx.rollback(); } s.close(); } }