我没看到你这么忙
Session session = sessionFactory.openSession();session.save(mc);session.flush();session.close();
但最可取的是
Session session = factory.openSession(); Transaction tx = null; try { tx = session.beginTransaction(); session.save(mc); tx.commit(); // Flush happens automatically } catch (RuntimeException e) { tx.rollback(); throw e; // or display error message } finally { session.close(); }


