home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / ddetour.bin / DBA_registrationRecord.java < prev    next >
Text File  |  1998-03-19  |  4KB  |  135 lines

  1. import symantec.itools.db.beans.jdbc.*;
  2. import symantec.itools.db.beans.binding.*;
  3. import java.util.*;
  4. import java.sql.*;
  5.  
  6. public class DBA_registrationRecord extends RecordDefinition
  7. {
  8.     public static   Statement m_InsertStatement=null;
  9.     public          Statement m_UpdateStatement=null;
  10.     public          Statement m_DeleteStatement=null;
  11.     static          DataModel m_DataModel = null;
  12.  
  13.     private static int counter = 0;
  14.  
  15.     public DBA_registrationRecord()
  16.     {
  17.         synchronized (this) {
  18.             if (counter == 0) {
  19.                 init();
  20.             }
  21.             counter++;
  22.         }
  23.     }
  24.  
  25.     public void init()
  26.     {
  27.         //{{INIT_CONTROLS
  28.         setConnectionManagerClassName("ConnectionManager1");
  29.         setConnectionName("jdbcConnection1");
  30.         setTableName("DBA.registration");
  31.         addColumn("Package_ID");
  32.         addColumn("Customer_First_Name");
  33.         addColumn("Customer_Last_Name");
  34.         addColumn("Customer_Email");
  35.         addColumn("Customer_Phone");
  36.         addColumn("Number_in_Party");
  37.         addColumn("Total_Cost");
  38.         addColumn("Registration_ID");
  39.         //}}
  40.     }
  41.  
  42.     public synchronized void setDataModel(PersistentObjectModel model)
  43.     {
  44.         m_DataModel = (DataModel)model;
  45.     }
  46.  
  47.    // getDataModel
  48.    // Returns the data model for this class.
  49.    // If the data model has not been generated call generateDataModel
  50.    // generateDataModel executes a query and builds the data model from the result
  51.    // If you want to customize the data model create it here instead of calling generate data model
  52.  
  53.     public synchronized PersistentObjectModel getDataModel()
  54.     {
  55.         if (m_DataModel == null) {
  56.             try {
  57.                 m_DataModel = generateDataModel();
  58.             }
  59.             catch (Exception ex) {
  60.                 throw new RuntimeException(ex.getMessage());
  61.             }
  62.         }
  63.         return m_DataModel;
  64.     }
  65.  
  66.    // getInsertStatement
  67.    // Returns a Statement object used to perform an INSERT operation.
  68.    // If you want to customize the INSERT operation write your own code in this method.
  69.    // If you bypass getStatement, you should also bypass setParameterValues,
  70.    // since the parameters must be set in accordance with the Statement.
  71.  
  72.     protected synchronized Statement getInsertStatement() throws SQLException
  73.     {
  74.         PreparedStatement psmd = (PreparedStatement)m_InsertStatement;
  75.         if (psmd==null) {
  76.             psmd = getStatement(psmd,INSERT_SQL);
  77.         }
  78.         setParameterValues(psmd);
  79.         return psmd;
  80.     }
  81.  
  82.    // getUpdateStatement
  83.    // Returns a Statement object used to perform an UPDATE operation.
  84.    // If you want to customize the UPDATE operation write your own code in this method.
  85.    // If you bypass getStatement, you should also bypass setParameterValues,
  86.    // since the parameters must be set in accordance with the Statement.
  87.  
  88.     protected synchronized Statement getUpdateStatement() throws SQLException
  89.     {
  90.         PreparedStatement psmd=(PreparedStatement)m_UpdateStatement;
  91.         psmd = getStatement(psmd,UPDATE_SQL);
  92.         setParameterValues(psmd);
  93.         setParameters(psmd,ORIGINAL_VALUE,getColModif(),false);
  94.         return psmd;
  95.     }
  96.  
  97.    // getDeleteStatement
  98.    // Returns a Statement object used to perform an DELETE operation.
  99.    // If you want to customize the DELETE operation write your own code in this method.
  100.    // If you bypass getStatement, you should also bypass setParameterValues,
  101.    // since the parameters must be set in accordance with the Statement.
  102.  
  103.     protected synchronized Statement getDeleteStatement() throws SQLException
  104.     {
  105.         PreparedStatement psmd=(PreparedStatement)m_DeleteStatement;
  106.         if (psmd==null) {
  107.             psmd = getStatement(psmd,DELETE_SQL);
  108.         }
  109.         setParameters(psmd,ORIGINAL_VALUE,0,false);
  110.         return psmd;
  111.     }
  112.  
  113.    // save
  114.    // This is the top level method for performing a save.
  115.    // If you want to customize DML you should write code in one of the above methods.
  116.    // You should modify the code of this method if you want to add additional functionality.
  117.    // For instance you may want to fire an event which indicates success or failure.
  118.  
  119.     public synchronized int save()
  120.     {
  121.         return super.save();
  122.     }
  123.  
  124.     protected  synchronized  void finalize() throws Throwable
  125.     {
  126.         counter--;
  127.         if (counter == 0) {
  128.             releaseConnection();
  129.         }
  130.     }
  131.  
  132. //{{DECLARE_CONTROLS
  133.     //}}
  134. }
  135.