hibernate<6>----组建关系映射
Name.java
hibernate.cfg.xmlpackage cn.anycall.hibernate;import java.util.Date;import org.hibernate.Session;import org.hibernate.Transaction;import cn.anycall.hibernate.domain.Name;import cn.anycall.hibernate.domain.User;public class Zujian {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubadd();}static void add(){Session s = null;Transaction tx = null;try{s = HibernateUtil.getSession();tx = s.beginTransaction();User u = new User();Name n = new Name();n.setFirstName("first name");n.setLastName("last name");u.setBirthday(new Date());u.setName(n);s.save(u);tx.commit();System.out.println("end");}finally{if(s!=null)s.close();}}}