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

📄 compuserdao.java

📁 hibernate应用测试,初学hibernate 的会员可以看看.
💻 JAVA
字号:
package com.dao;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.ibatis.common.resources.Resources;

import java.io.Reader;
import java.io.IOException;
import java.util.List;
import java.sql.SQLException;

import com.tool.pagetool.*;
import com.bean.*;
//import com.ibatis.common.util.PaginatedList;
public class CompUserDAO extends PageDAO{
    public static List selectAllCompUser() throws SQLException {
        return sqlMapper.queryForList("selectAllCompUser");
   }

   public static List selectAllCompUserUI() throws SQLException {
    return sqlMapper.queryForList("selectAllCompUserUI");
}

   public static CompUser selectCompUserBycompUserId(int id) throws SQLException {
       return (CompUser) sqlMapper.queryForObject("selectCompUserBycompUserId",       new Integer(id));
   }

   public static void insertCompUser(CompUser compuser) throws SQLException {
      sqlMapper.insert("insertCompUser", compuser);
   }

   public static void updateCompUser(CompUser compuser) throws SQLException {
       sqlMapper.update("updateCompUser", compuser);
   }

   public static void deleteCompUserBycompUserId(int id) throws SQLException {
        sqlMapper.delete("deleteCompUserBycompUserId", new Integer(id));
    }

    public static int getLastId() throws SQLException{
        Object obj = sqlMapper.queryForObject("selectCompUserLastId");
        if(obj==null) return 0;
        else
        return ((Integer)obj).intValue();
    }

    public static boolean isHasCompuser(String whereStr) throws SQLException{
        //Page tmpPage = new Page();
        //tmpPage.setQueryStr(whereStr);
        Object obj = sqlMapper.queryForObject("selectIsHasCompUser",whereStr);
        return obj==null?false:true;
    }

    public static boolean isHasReferCompUser(CompUser compUser)throws SQLException{
        boolean flag = false;
//        System.out.println("compUser2.getIsUsed()="+compUser2.getIsUsed());
        Object obj = sqlMapper.queryForObject("isHasReferCompUser",compUser);
        CompUser compUser2 = (CompUser)obj;
//        System.out.println("compUser2.getIsUsed()="+compUser2.getIsUsed());
        if(compUser2.getIsUsed()>0) flag=true;
        return flag;
    }

//    public static PaginatedList selectForSysPage(Page page)throws SQLException{
//        PaginatedList list = sqlMapper.queryForPaginatedList("selectCompUserSysPage",page,page.getSize());
//        return list;
//    }

   public int selectCount(Page page) throws SQLException{
        return ((Integer)sqlMapper.queryForObject("selectCompUserCount",page)).intValue();
    }

    public int selectCount() throws SQLException{
       return ((Integer)sqlMapper.queryForObject("selectCompUserCountNotP")).intValue();
   }


   public List selectForPage(Page page) throws SQLException{
        List pageList = sqlMapper.queryForList("selectCompUserForPage",page);
        return pageList;
    }

   public static void startTransation()throws SQLException{
        sqlMapper.startTransaction();
    }

     public static void startTransation(int i)throws SQLException{
        sqlMapper.startTransaction(i);
     }

   public static void rollback() throws SQLException{
        sqlMapper.endTransaction();
     }

   public static void commit()throws SQLException{
        sqlMapper.commitTransaction();
    }
//    public static void main(String[] args) throws Exception{
////        Page page = new Page();
////        page.setSize(20);
////        page.setCurrentPage(2);
//       List list= PageToolBuilder.builder(new CompUserDAO()).createPage(500,20,"where department like'%技术部1%'").getPage();
////        page.setQueryStr("where department like'%技术部1%'");
////        PaginatedList list = CompUserDAO.selectForSysPage(page);
////        list.nextPage();
////        list.gotoPage(10);
////        List list = new CompUserDAO().selectForPage(page);
//        for(int i = 1;i<list.size();i++){
//            CompUser compUser = (CompUser)list.get(i);
//            System.out.println(compUser.getCompUserId()+"\t"+compUser.getRealName());
//        }
//    }

}

⌨️ 快捷键说明

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