⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 hibernate练习的最佳的代码
💻 JAVA
字号:
package com.tarena.ebank.view;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.tarena.ebank.biz.entriy.Account;



public class Test {
	public static void main(String[] args) {
	  SessionFactory sf = 
		  new Configuration()
              .configure()
              .buildSessionFactory();
	  Account act = 
		  new Account("act-0015",6.0);
      Session s = sf.openSession();
      
      try {
		  s.beginTransaction();
		  s.save(act);
		 
		  
		  try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  s.getTransaction().commit();
		 
	  } catch (HibernateException e) {
		  e.printStackTrace();
		  s.getTransaction().rollback();
	  }finally{
		  s.close();
		  sf.close();
	  }
      
      
 	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -