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

📄 recvdocformpersistentbase.java

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

/*
 * RecvDocFormPersistentBase.java
 * Generated using xgen and texen from beanpersistentbase.vm
 * Fri Mar 19 19:34:55 CST 2004
 */

package com.sure.oa.recvdoc;

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  RecvDocFormPersistentBase {

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

  public RecvDocFormPersistentBase(RecvDocForm bean) { setBean(bean); }
  public RecvDocFormPersistentBase(RecvDocForm bean, boolean recordExists) { setBean(bean); setRecordExists(recordExists); }


  public RecvDocForm getBean() { return bean; }
  public void setBean(RecvDocForm 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 RecvDocForm load(ResultSet rs) throws SQLException {
    RecvDocForm theBean = new RecvDocForm ();
    try{ theBean.setDocId ( rs.getInt("docId") ); } catch(NullPointerException e){}
    try{ theBean.setDocKind ( rs.getString("docKind") ); } catch(NullPointerException e){}
    try{ theBean.setSendDocId ( rs.getInt("sendDocId") ); } 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.setPublishPerson ( rs.getString("publishPerson") ); } catch(NullPointerException e){}
    try{ theBean.setPublishDate ( rs.getTimestamp("publishDate") ); } 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.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.setSealName ( rs.getString("sealName") ); } catch(NullPointerException e){}
    try{ theBean.setSubject ( rs.getString("subject") ); } catch(NullPointerException e){}
    try{ theBean.setAllUnit ( rs.getString("allUnit") ); } catch(NullPointerException e){}
    try{ theBean.setSendUnitName ( rs.getString("sendUnitName") ); } catch(NullPointerException e){}
    try{ theBean.setSendUnitId ( rs.getString("sendUnitId") ); } 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.setReceiveNo ( rs.getString("ReceiveNo") ); } catch(NullPointerException e){}
    try{ theBean.setMemo ( rs.getString("memo") ); } 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,sendDocId,docTitle,CreateDate,creator,createunitId,secret,emergency,saveTime,docNoPre,yearNo,waterNo,publishPerson,publishDate,allSignPerson,dealPerson,checkPerson,printUnit,printDate,mainDealunit,sendTo,cc,reportTo,inerTo,sealName,subject,allUnit,sendUnitName,sendUnitId,sendTime,sendPerson,filePages,attachmentPages,printnumber,ReceiveNo,memo FROM RecvDocForm " + where;
    ResultSet rs = s.executeQuery( sql );
    while(rs.next()){
      RecvDocForm theBean = new RecvDocForm ();
      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,sendDocId,docTitle,CreateDate,creator,createunitId,secret,emergency,saveTime,docNoPre,yearNo,waterNo,publishPerson,publishDate,allSignPerson,dealPerson,checkPerson,printUnit,printDate,mainDealunit,sendTo,cc,reportTo,inerTo,sealName,subject,allUnit,sendUnitName,sendUnitId,sendTime,sendPerson,filePages,attachmentPages,printnumber,ReceiveNo,memo FROM RecvDocForm " + where;
    ResultSet rs = s.executeQuery( sql );
    while(rs.next()){
      RecvDocForm theBean = new RecvDocForm ();
      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,sendDocId,docTitle,CreateDate,creator,createunitId,secret,emergency,saveTime,docNoPre,yearNo,waterNo,publishPerson,publishDate,allSignPerson,dealPerson,checkPerson,printUnit,printDate,mainDealunit,sendTo,cc,reportTo,inerTo,sealName,subject,allUnit,sendUnitName,sendUnitId,sendTime,sendPerson,filePages,attachmentPages,printnumber,ReceiveNo,memo FROM RecvDocForm ";
    if(where.length() > 0)
      sql = sql + where;
    Statement s = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                       ResultSet.CONCUR_READ_ONLY);
    s.setMaxRows(startRow + rowCount - 1);
    ResultSet rs = s.executeQuery( sql );
    rs.absolute(startRow);

    do {
      RecvDocForm theBean = new RecvDocForm ();
      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

⌨️ 快捷键说明

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