1、三種狀態的區分關鍵在于
A、有沒有ID
B、ID在數據庫中有沒有
C、在內存中有沒有(session緩存)

2、三種狀態說明
A、transient:內存中一個對象,沒ID,緩存中也沒有
B、persistent:內存中有,緩存中有,數據庫有(存在ID)
C、detached:內存有,緩存沒有,數據庫有(存在ID)

        TeacherPK pk = new TeacherPK();
        pk.setId(
4);
        pk.setName(
"t1");
        Teacher t 
= new Teacher();
        t.setPk(pk);
        t.setTitle(
"高級");
        t.setBirthDate(
new Date());
        t.setStatus(Status.sNormal);
        
//t    ->    transient

        Session session 
= sessionFactory.getCurrentSession();
        session.beginTransaction();
        session.save(t);
        session.getTransaction().commit();
        
//t   ->     persistent
        
        System.out.println(t.getTitle());
        
//t   ->     detached