package teine; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.AnnotationConfiguration; public class Test1 { public static void main(String[] arg){ SessionFactory sf = new AnnotationConfiguration(). configure("teine/hibernate1.cfg.xml").buildSessionFactory(); Session s=sf.openSession(); Transaction tx=s.beginTransaction(); try{ Hobune h=new Hobune(); h.setHobusenimi("Miilu"); h.setToon("hall"); s.save(h); TraavelHobune t=new TraavelHobune(); t.setHobusenimi("Pinna"); t.setToon("kõrb"); t.setKutsar("Tamm"); s.save(t); tx.commit(); } catch(Exception ex){ ex.printStackTrace(); } } }