81,122
社区成员




import org.hibernate.Session;
import org.hibernate.Transaction;
import net.sf.ehcache.hibernate.HibernateUtil;
public class PersonManager {
public static void main(String [] args)
{
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Person p = new Person();
Address a = new Address("Guangzhou tianhe");
p.setName("crazyit.org");
p.setAge(21);
p.setAddress(a);
session.persist(p);
Address a2 = new Address("Shanghai hongkou");
p.setAddress(a2);
tx.commit();
HibernateUtil.closeSession();
}
}