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

📄 senddocformpersistentbase.java

📁 OA典型例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

/*
 * SendDocFormPersistentBase.java
 * Generated using xgen and texen from beanpersistentbase.vm
 * Sun Mar 21 16:06:40 CST 2004
 */

package com.sure.oa.senddoc;

import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.DatabaseMetaData;
import java.sql.BatchUpdateException;
import java.math.BigDecimal;
import com.sure.businessmodel.Page;
import java.io.*;
import java.util.*;
import com.sure.util.database.*;

/**
 * 存取发文单主信息的属性
 * @author datonghuiren@sohu.com
 */
public abstract class SendDocFormPersistentBase {

  /** class attributes */
  transient protected boolean recordExists = false;
  transient protected boolean handleConcurrency = false;
  transient protected boolean handleAutoIncrement = true;
  protected SendDocForm bean;

  public SendDocFormPersistentBase(SendDocForm bean) { setBean(bean); }
  public SendDocFormPersistentBase(SendDocForm bean, boolean recordExists) { setBean(bean); setRecordExists(recordExists); }


  public SendDocForm getBean() { return bean; }
  public void setBean(SendDocForm bean) { this.bean = bean; }
  public boolean getRecordExists() { return recordExists; }
  public void setRecordExists(boolean recordExists) { this.recordExists = recordExists; }

  /**
   * Load this object from a result set
   * If null fields are present in the table, catch the NullPointerException
   */
  public static SendDocForm load(ResultSet rs) throws SQLException {
    SendDocForm theBean = new SendDocForm ();
    try{ theBean.setDocId ( rs.getInt("docId") ); } catch(NullPointerException e){}
    try{ theBean.setDocKind ( rs.getString("docKind") ); } catch(NullPointerException e){}
    try{ theBean.setDocTitle ( rs.getString("docTitle") ); } catch(NullPointerException e){}
    try{ theBean.setCreateDate ( rs.getTimestamp("createDate") ); } catch(NullPointerException e){}
    try{ theBean.setCreator ( rs.getString("creator") ); } catch(NullPointerException e){}
    try{ theBean.setCreateUnitId ( rs.getString("createUnitId") ); } catch(NullPointerException e){}
    try{ theBean.setSecret ( rs.getString("secret") ); } catch(NullPointerException e){}
    try{ theBean.setEmergency ( rs.getString("emergency") ); } catch(NullPointerException e){}
    try{ theBean.setSaveTime ( rs.getString("saveTime") ); } catch(NullPointerException e){}
    try{ theBean.setDocNoPre ( rs.getString("docNoPre") ); } catch(NullPointerException e){}
    try{ theBean.setYearNo ( rs.getString("yearNo") ); } catch(NullPointerException e){}
    try{ theBean.setWaterNo ( rs.getString("waterNo") ); } catch(NullPointerException e){}
    try{ theBean.setPublishDate ( rs.getTimestamp("publishDate") ); } catch(NullPointerException e){}
    try{ theBean.setPublishPerson ( rs.getString("publishPerson") ); } catch(NullPointerException e){}
    try{ theBean.setAllSignPerson ( rs.getString("allSignPerson") ); } catch(NullPointerException e){}
    try{ theBean.setDealPerson ( rs.getString("dealPerson") ); } catch(NullPointerException e){}
    try{ theBean.setCheckPerson ( rs.getString("checkPerson") ); } catch(NullPointerException e){}
    try{ theBean.setPrintUnit ( rs.getString("printUnit") ); } catch(NullPointerException e){}
    try{ theBean.setPrintDate ( rs.getTimestamp("printDate") ); } catch(NullPointerException e){}
    try{ theBean.setMainDealunit ( rs.getString("mainDealunit") ); } catch(NullPointerException e){}
    try{ theBean.setCombine ( rs.getString("combine") ); } catch(NullPointerException e){}
    try{ theBean.setCombineUnit ( rs.getString("combineUnit") ); } catch(NullPointerException e){}
    try{ theBean.setSendTo ( rs.getString("sendTo") ); } catch(NullPointerException e){}
    try{ theBean.setCc ( rs.getString("cc") ); } catch(NullPointerException e){}
    try{ theBean.setReportTo ( rs.getString("reportTo") ); } catch(NullPointerException e){}
    try{ theBean.setInerTo ( rs.getString("inerTo") ); } catch(NullPointerException e){}
    try{ theBean.setSubject ( rs.getString("subject") ); } catch(NullPointerException e){}
    try{ theBean.setSealTime ( rs.getTimestamp("sealTime") ); } catch(NullPointerException e){}
    try{ theBean.setSealPerson ( rs.getString("sealPerson") ); } catch(NullPointerException e){}
    try{ theBean.setSealName ( rs.getString("sealName") ); } catch(NullPointerException e){}
    try{ theBean.setSendTime ( rs.getTimestamp("sendTime") ); } catch(NullPointerException e){}
    try{ theBean.setSendPerson ( rs.getString("sendPerson") ); } catch(NullPointerException e){}
    try{ theBean.setFilePages ( rs.getInt("filePages") ); } catch(NullPointerException e){}
    try{ theBean.setAttachmentPages ( rs.getInt("attachmentPages") ); } catch(NullPointerException e){}
    try{ theBean.setPrintnumber ( rs.getInt("printnumber") ); } catch(NullPointerException e){}
    try{ theBean.setDelPerson ( rs.getString("delPerson") ); } catch(NullPointerException e){}
    try{ theBean.setDelTime ( rs.getTimestamp("delTime") ); } catch(NullPointerException e){}
    try{ theBean.setDelYy ( rs.getString("delYy") ); } catch(NullPointerException e){}
    try{ theBean.setDocMemo ( rs.getString("docMemo") ); } catch(NullPointerException e){}
    try{ theBean.setStatus ( rs.getString("status") ); } catch(NullPointerException e){}
    try{ theBean.setSealConfirm ( rs.getString("sealConfirm") ); } catch(NullPointerException e){}
    return theBean;
  }

  /**
   * Load a range of records from a connection, according to the where clause.
   * Returns a map of records accessible by a column value. (ie: foreign key)
   */
  public static Map loadByKey(Connection conn, String where, String colname)
    throws SQLException{

    HashMap map = new HashMap();
    Statement s = conn.createStatement();
    String sql = "SELECT docId,docKind,docTitle,createDate,creator,createUnitId,secret,emergency,saveTime,docNoPre,yearNo,waterNo,publishDate,publishPerson,allSignPerson,dealPerson,checkPerson,printUnit,printDate,mainDealunit,combine,combineUnit,sendTo,cc,reportTo,inerTo,subject,sealTime,sealPerson,sealName,sendTime,sendPerson,filePages,attachmentPages,printnumber,delPerson,delTime,delYy,docMemo,status,sealConfirm FROM SendDocForm " + where;
    ResultSet rs = s.executeQuery( sql );
    while(rs.next()){
      SendDocForm theBean = new SendDocForm ();
      int col = rs.findColumn(colname);
      String key = rs.getString(col);
      theBean = load(rs);
      map.put(key, theBean);
    }
    rs.close();
    s.close();
    return map;
  }

  /**
   * Load a range of records from a connection, according to the where clause
   */
  public static Vector load(Connection conn, String where) throws SQLException{
    Vector beans = new Vector();
    Statement s = conn.createStatement();
    String sql = "SELECT docId,docKind,docTitle,createDate,creator,createUnitId,secret,emergency,saveTime,docNoPre,yearNo,waterNo,publishDate,publishPerson,allSignPerson,dealPerson,checkPerson,printUnit,printDate,mainDealunit,combine,combineUnit,sendTo,cc,reportTo,inerTo,subject,sealTime,sealPerson,sealName,sendTime,sendPerson,filePages,attachmentPages,printnumber,delPerson,delTime,delYy,docMemo,status,sealConfirm FROM SendDocForm " + where;
    ResultSet rs = s.executeQuery( sql );
    while(rs.next()){
      SendDocForm theBean = new SendDocForm ();
      theBean = load(rs);
      beans.addElement(theBean);
    }
    rs.close();
    s.close();
    return beans;
  }

  /**
   * Load a range of records using a scrollable resultset and absolute cursor
   */
  public static Vector load(Connection conn, String where,
      int startRow, int rowCount) throws SQLException {
    Vector beans = new Vector();

    String sql = "SELECT docId,docKind,docTitle,createDate,creator,createUnitId,secret,emergency,saveTime,docNoPre,yearNo,waterNo,publishDate,publishPerson,allSignPerson,dealPerson,checkPerson,printUnit,printDate,mainDealunit,combine,combineUnit,sendTo,cc,reportTo,inerTo,subject,sealTime,sealPerson,sealName,sendTime,sendPerson,filePages,attachmentPages,printnumber,delPerson,delTime,delYy,docMemo,status,sealConfirm FROM SendDocForm ";
    if(where.length() > 0)
      sql = sql + where;
    Statement s = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                       ResultSet.CONCUR_READ_ONLY);
    s.setMaxRows(startRow + rowCount - 1);
    System.out.println("sendocformperbase: sql = "+sql);
    ResultSet rs = s.executeQuery( sql );
    rs.absolute(startRow);

    do {
      SendDocForm theBean = new SendDocForm ();
      theBean = load(rs);
      beans.addElement(theBean);
    } while(rs.next());
    rs.close();
    s.close();
    return beans;
  }

  /**
   * Load a Page of records using a scrollable resultset and absolute cursor
   */
  public static Page load(Connection conn, int startRow, int pageSize,
       String where) throws SQLException {

    int count = getCount(conn, where);
    if (count == 0) return new Page(pageSize);
    startRow = Page.getValidStart(startRow, count, pageSize);
    Vector beans = load(conn, where, startRow, pageSize);
    return new Page(beans, startRow, count, pageSize);
  }

  /**
   * Persist the record. Performs a sql update or insert.
   * The primary key will be "set" upon insert.
   * If autocommit is on, turn it off to make a transactional
   * check of the tcn field.
   */
  public void persist(Connection conn) throws SQLException{
    if(recordExists){
      if(handleConcurrency){
        //regenerate source if you want the bean to handle concurrency
      }else{
        update(conn);
      }
    }else{
      if(handleAutoIncrement){
        setPrimaryKey(conn);
      }
      insert(conn);
    }
  }



  /**
    * Set the primary key field using the MAX value of the column
    * If the primary key is a string, check for existence and return
    * If the primary key is already set (in a new bean its 0) return
    */
    public void setPrimaryKey(Connection conn) throws SQLException{
            try{
      IDGeneratorManager idGeneratorManager = new IDGeneratorManager();

⌨️ 快捷键说明

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