?? test.java
字號:
package com.sterning.bean.hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import com.sterning.books.model.Books;
public class Test {
public static void main(String[] args) {
try {
SessionFactory sf =
new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
Books pd = new Books();
pd.setBookId("1");
pd.setBookName("教父");
pd.setBookAuthor("Godfather");
pd.setBookPublish("1");
pd.setBookIsbn("DVD");
session.save(pd);
tx.commit();
session.close();
} catch (HibernateException e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -