Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mesut.embeddedembedable; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; /** * * @author mesut */ public class Main { public static void main(String[] args) { Uye uye = new Uye(); uye.setAdi("Ahmet"); uye.setSoyadi("Demir"); Adres adres = new Adres(); adres.setSehir("Ankara"); adres.setIlce("ankaya"); adres.setMahalle("mahalle"); adres.setCadde("cadde"); uye.setAdres(adres); //------------------------------------ SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session session = sf.openSession(); session.beginTransaction(); session.save(uye); session.getTransaction().commit(); session.close(); sf.close(); } }