📄 viewbean.java
字号:
package pp;
import java.util.Collection;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class ViewBean
{
private Session jj;
private List kk,kk1,kk2;
public ViewBean()
{
Configuration oo=new Configuration();
oo.configure();
SessionFactory sfy=oo.buildSessionFactory();
jj=sfy.openSession();
}
public Collection getDepartment()
{
try
{
Query aa=jj.createQuery("from Department");
kk=aa.list();
}catch(Exception e){System.out.print(e);}
return kk;
}
public Collection getEmployee()
{
try
{
Query aa=jj.createQuery("from Employee");
kk1=aa.list();
}catch(Exception e){System.out.print(e);}
return kk1;
}
public Collection getQueryemp(String pp)
{
try
{
Query aa=jj.createQuery("select e,d from Employee e,Department d " +
"where e.id=? and d.id=e.departmentBean.id");
aa.setString(0,pp);
kk2=aa.list();
}catch(Exception e){System.out.print(e);}
return kk2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -