2013-04-02 75 views

回答

0

類似這樣的:

public boolean syncronize(Class hibernateClass, Session from, Session to) throws HibernateException 
    { 
      Transaction transaction = to.beginTransaction(); 
      List newData = from.createCriteria(hibernateClass).list(); 
      for (Iterator iter = newData.iterator(); iter.hasNext();) 
       { 
        Object element = (Object) iter.next(); 
        from.evict(element); 
        to.replicate(element,ReplicationMode.OVERWRITE); 
       } 
      transaction.commit(); 
    } 
相關問題