?? deletebyselectbo.java
字號:
package com.free.hibernate.delete;
import org.hibernate.*;
import org.hibernate.cfg.*;
import com.free.hibernate.bo.Contact;
import com.free.hibernate.util.HibernateUtil;
import java.util.*;
/**
* <p>Title: Eclipse Plugin Development</p>
* <p>Description: Free download</p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: Free</p>
* @author gan.shu.man
* @version 1.0
*/
public class DeleteBySelectBO {
public static void main(String[] args) {
HibernateUtil.buildSessionFactory();
Session session = HibernateUtil.currentSession();
String SQL_QUERY = "from Contact";
Query query = session.createQuery(SQL_QUERY);
for (Iterator it = query.iterate(); it.hasNext();) {
Contact contact = (Contact) it.next();
//刪除firstName為wang的所有記錄
if (contact.getFirstName().equals("wang")){
session.delete(contact);
}
}
session.flush();
session.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -