home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / ddetour.bin / DBA_packagesRecord.java < prev    next >
Encoding:
Java Source  |  1998-03-19  |  4.2 KB  |  134 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_packagesRecord 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_packagesRecord()
  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.packages");
  31.         addColumn("Package_ID");
  32.         addColumn("Package_Name");
  33.         addColumn("Start_Date");
  34.         addColumn("Number_of_Days");
  35.         addColumn("Price_Per_Person");
  36.         addColumn("Image");
  37.         addColumn("Description");
  38.         //}}
  39.     }
  40.  
  41.     public synchronized void setDataModel(PersistentObjectModel model)
  42.     {
  43.         m_DataModel = (DataModel)model;
  44.     }
  45.  
  46.    // getDataModel
  47.    // Returns the data model for this class.
  48.    // If the data model has not been generated call generateDataModel
  49.    // generateDataModel executes a query and builds the data model from the result
  50.    // If you want to customize the data model create it here instead of calling generate data model
  51.  
  52.     public synchronized PersistentObjectModel getDataModel()
  53.     {
  54.         if (m_DataModel == null) {
  55.             try {
  56.                 m_DataModel = generateDataModel();
  57.             }
  58.             catch (Exception ex) {
  59.                 throw new RuntimeException(ex.getMessage());
  60.             }
  61.         }
  62.         return m_DataModel;
  63.     }
  64.  
  65.    // getInsertStatement
  66.    // Returns a Statement object used to perform an INSERT operation.
  67.    // If you want to customize the INSERT operation write your own code in this method.
  68.    // If you bypass getStatement, you should also bypass setParameterValues,
  69.    // since the parameters must be set in accordance with the Statement.
  70.  
  71.     protected synchronized Statement getInsertStatement() throws SQLException
  72.     {
  73.         PreparedStatement psmd = (PreparedStatement)m_InsertStatement;
  74.         if (psmd==null) {
  75.             psmd = getStatement(psmd,INSERT_SQL);
  76.         }
  77.         setParameterValues(psmd);
  78.         return psmd;
  79.     }
  80.  
  81.    // getUpdateStatement
  82.    // Returns a Statement object used to perform an UPDATE operation.
  83.    // If you want to customize the UPDATE operation write your own code in this method.
  84.    // If you bypass getStatement, you should also bypass setParameterValues,
  85.    // since the parameters must be set in accordance with the Statement.
  86.  
  87.     protected synchronized Statement getUpdateStatement() throws SQLException
  88.     {
  89.         PreparedStatement psmd=(PreparedStatement)m_UpdateStatement;
  90.         psmd = getStatement(psmd,UPDATE_SQL);
  91.         setParameterValues(psmd);
  92.         setParameters(psmd,ORIGINAL_VALUE,getColModif(),false);
  93.         return psmd;
  94.     }
  95.  
  96.    // getDeleteStatement
  97.    // Returns a Statement object used to perform an DELETE operation.
  98.    // If you want to customize the DELETE operation write your own code in this method.
  99.    // If you bypass getStatement, you should also bypass setParameterValues,
  100.    // since the parameters must be set in accordance with the Statement.
  101.  
  102.     protected synchronized Statement getDeleteStatement() throws SQLException
  103.     {
  104.         PreparedStatement psmd=(PreparedStatement)m_DeleteStatement;
  105.         if (psmd==null) {
  106.             psmd = getStatement(psmd,DELETE_SQL);
  107.         }
  108.         setParameters(psmd,ORIGINAL_VALUE,0,false);
  109.         return psmd;
  110.     }
  111.  
  112.    // save
  113.    // This is the top level method for performing a save.
  114.    // If you want to customize DML you should write code in one of the above methods.
  115.    // You should modify the code of this method if you want to add additional functionality.
  116.    // For instance you may want to fire an event which indicates success or failure.
  117.  
  118.     public synchronized int save()
  119.     {
  120.         return super.save();
  121.     }
  122.  
  123.     protected  synchronized  void finalize() throws Throwable
  124.     {
  125.         counter--;
  126.         if (counter == 0) {
  127.             releaseConnection();
  128.         }
  129.     }
  130.  
  131. //{{DECLARE_CONTROLS
  132.     //}}
  133. }
  134.