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

📄 test.java

📁 采用hibernate2.x框架,数据库采用sqlserver2000,封装了hibernage操作工具类
💻 JAVA
字号:
import com.HiberDb;
import com.HiberDbImpl;
import com.Dept;
import com.Emp;
import java.util.*;

public class Test 
{
    public static void main(String[] args) throws Exception
    {
        HiberDb hdb = new HiberDbImpl();
    /*    Dept d = new Dept();
        d.setDname("技术部");
        d.setAddress("XXXXXXXXXXXX10");
        
        hdb.update(d,hdb.INSERT);
     */   
     /*   Emp e = new Emp();
        e.setEmpno(new Integer(104));
        e.setEname("fff");
        Dept d = (Dept)hdb.selectSingle("from Dept d where d.deptno=1");
        e.setDept(d);
        
        List l = new ArrayList();
        l.add(e);
        
        Emp e1 = new Emp();
        e1.setEmpno(new Integer(101));
        e1.setEname("yyy");
		e1.setDept(d);        
        l.add(e1);
        
        hdb.update(l, hdb.INSERT);
  
   
   *///update
     /*   Emp e = (Emp)hdb.selectSingle("from Emp e where e.empno=100");
        e.setEname("wang dwei");
        hdb.update(e, hdb.UPDATE);
   */

   //delete
     //   Emp e = (Emp)hdb.selectSingle("from Emp e where e.empno=100");
    //    hdb.update(e, hdb.DELETE);
   

   /*  List l = hdb.selectList("select e.ename,e.empno from Emp e");
       for(int i=0; i<l.size();i++)
       {
       	   Object s[] = (Object[])l.get(i);
       	   System.out.println(s[0]);
       	   System.out.println(s[1]);
       }
     
   
       List l = hdb.selectList("from Emp");
       for(int i=0; i<l.size();i++)
       {
       	   Emp e = (Emp)l.get(i);
       	   System.out.println(e.getEname());
       }
     
     
   */
   /*  List l = hdb.selectList("from Emp e where e.dept.deptno=1");
       for(int i=0; i<l.size();i++)
       {
       	   Emp e = (Emp)l.get(i);
       	   System.out.println(e.getEname());
       }
   */  
     
       Dept d = (Dept)hdb.selectSingle("from Dept d where deptno=1");
       Set s = d.getEmps();
       Iterator it = s.iterator();
       
  	   while(it.hasNext())
  	   {
  	     	   Emp e = (Emp)it.next();
       	   System.out.println(e.getEname());
  	   }
	}
}

⌨️ 快捷键说明

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