?? mgr.java
字號:
package cssrain.mgr;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import rain.db.HibernateSessionFactory;
/**
* @author 浙江寧波德威科技有限公司.程序員:單東林
* @version 創建時間:2008-1-23 下午11:41:51
* 類說明:
*/
public class Mgr {
public List getSel1()
{
Session session = null;
List custList = new ArrayList();
try
{
session = HibernateSessionFactory.getSession();
Transaction ts=session.beginTransaction();
String hql = "from Cssrain ";
Query query = session.createQuery(hql);
custList = query.list();
}
catch(HibernateException e)
{
custList = null;
System.out.println("There are errors in getting getSel1!");
e.printStackTrace();
}
finally
{
session.clear();
HibernateSessionFactory.closeSession();
}
return custList;
}
public List getSel2(String condition)
{
Session session = null;
List custList = new ArrayList();
if(condition == null) condition = "";
try
{
session = HibernateSessionFactory.getSession();
Transaction ts=session.beginTransaction();
String hql = "from Test c where c.name='"+condition+"' ";
Query query = session.createQuery(hql);
custList = query.list();
}
catch(HibernateException e)
{
custList = null;
System.out.println("There are errors in getting getSel2!");
e.printStackTrace();
}
finally
{
session.clear();
HibernateSessionFactory.closeSession();
}
return custList;
}
public List getSel3(String condition)
{
Session session = null;
List custList = new ArrayList();
if(condition == null) condition = "";
try
{
session = HibernateSessionFactory.getSession();
Transaction ts=session.beginTransaction();
String hql = "from Student c where c.studentId='"+condition+"' ";
Query query = session.createQuery(hql);
custList = query.list();
}
catch(HibernateException e)
{
custList = null;
System.out.println("There are errors in getting getSel3!");
e.printStackTrace();
}
finally
{
session.clear();
HibernateSessionFactory.closeSession();
}
return custList;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -