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

📄 tcustomer_mrdfrk__weblogic_cmp_rdbms.java

📁 郭克华j2ee高级框架实战教学视频源代码 这个是比较值得一看的 由郭克华博士在总结多年Java培训的基础上
💻 JAVA
📖 第 1 页 / 共 4 页
字号:

  public String __WL_getM2NSQL(String cmrf, int operation)
  {
    return "";
  }

  public Collection __WL_getCmrBeansForCmrField(String cmrf)
  {
    return null;
  }


  // end of CMPBean
  // ================================================================


  //=================================================================
  // implementation of javax.ejb.EntityBean

  public boolean __WL_beanIsLoaded() { 
    return __WL_beanIsLoaded; 
  }

    void pkCheck()
    throws javax.ejb.CreateException
  {
    // check that 'account' was setif (!__WL_isModified[0]) {Loggable l = EJBLogger.logpkNotSetLoggable("TCustomer","account");throw new javax.ejb.CreateException(l.getMessage());}
  }


  public java.lang.String ejbCreate(java.lang.String arg0)
    throws javax.ejb.CreateException
  {
    int oldState = __WL_method_state;
    try {
      __WL_method_state = STATE_EJB_CREATE;

      for (int __WL_i = 0; __WL_i < 4; __WL_i++) {
        __WL_isLoaded[__WL_i] = true;
        __WL_isModified[__WL_i] = false;
      }

      __WL_beanIsLoaded = true;
      

      // set true, this prevents us from registering the bean until after the
      // database insert
      __WL_modifiedBeanIsRegistered = true;
      

      // initialize persistent and cached relationship variables, this
      // is done here purely to ensure robustness as the CMP variables
      // are also initialized whenever the bean enters the pooled state
      password = null;account = null;cbalance = null;cname = null;
      

      super.ejbCreate( arg0);

      pkCheck();

      

      java.lang.String __WL_pk = null;__WL_pk = (java.lang.String) __WL_getPrimaryKey();return __WL_pk;} catch (javax.ejb.CreateException ce) {throw ce;    } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }

    finally {
      __WL_method_state = oldState;
    }
  }


  public void ejbPostCreate(java.lang.String arg0)
    throws javax.ejb.CreateException
  {
    int oldState = __WL_method_state;
    try {
      __WL_method_state = STATE_EJB_POSTCREATE;

      

      super.ejbPostCreate( arg0);

      if (!__WL_pm.getOrderDatabaseOperations())__WL_create();

      

      } catch (javax.ejb.CreateException ce) {throw ce;

          } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }

    finally {
      __WL_method_state = oldState;
    }
  }


    private Object __WL_create() throws Exception {
    if (__WL_verbose) {
      Debug.say("called __WL_create.");
    }
    
    java.sql.Connection __WL_con = null;
    java.sql.PreparedStatement[] __WL_stmt_array = new java.sql.PreparedStatement[1];java.sql.PreparedStatement __WL_stmt_T_CUSTOMER_0 = null;__WL_stmt_array[0] = __WL_stmt_T_CUSTOMER_0;
    String[] __WL_query_array = new String[1];

    java.lang.String __WL_pk = null;

    try {
      
      __WL_pk = this.account;

      __WL_con = __WL_pm.getConnection();
      if(__WL_verbose) {
        Debug.say("__WL_create() got connection.");
      }

      __WL_query_array[0] = "INSERT INTO T_CUSTOMER (ACCOUNT, CBALANCE, CNAME, PASSWORD) VALUES (?, ?, ?, ?)";

      if (__WL_verbose) {
        for (int i = 0 ; i < 1 ; i++) {
          Debug.say("__WL_create() produced sqlString " + __WL_query_array[i]);
        }
      }

      if (__WL_query_array[0] != null) __WL_stmt_array[0] = __WL_con.prepareStatement(__WL_query_array[0]);

      __WL_setBeanParamsForCreateArray(__WL_stmt_array);

      if(__WL_verbose) {
        Debug.say("__WL_create() about to execute sql.");
      }
      for (int i = 0 ; i < 1 ; i++) {
        if (__WL_stmt_array[i].executeUpdate() != 1) {
          throw new java.lang.Exception("Failed to CREATE Bean.  Primary Key Value: '" + __WL_pk + "'");
        }
      }

      

      for (int __WL_i = 0; __WL_i < __WL_isModified.length; __WL_i++) {
        __WL_isModified[__WL_i] = false;
      }
      __WL_modifiedBeanIsRegistered = false;

      return __WL_pk;
    } catch (java.sql.SQLException se) {
            //ejb wants a duplicate key exception if that was what happened
      if(__WL_verbose) {
        Debug.say("__WL_create() "+
           "checking for duplicate key " + __WL_pk);
      }
      boolean exists = false;
      try {
        exists = __WL_exists(__WL_pk);
      }
      catch (Exception e) {
        throw se;
      }
      if (exists) {
        Loggable l = EJBLogger.logduplicateKeyFoundLoggable(__WL_pk.toString());
        throw new javax.ejb.DuplicateKeyException(
             l.getMessage());
       }
      else {
        throw se;
      }

    } finally {
      __WL_pm.releaseArrayResources(__WL_con, __WL_stmt_array, null);
    }
  }


  public void ejbRemove() throws javax.ejb.RemoveException {    java.sql.Connection __WL_con = null;
    java.sql.PreparedStatement[] __WL_stmt_array = new java.sql.PreparedStatement[1];java.sql.PreparedStatement __WL_stmt_T_CUSTOMER_0 = null;__WL_stmt_array[0] = __WL_stmt_T_CUSTOMER_0;
    String[] __WL_query_array = new String[1];
    
    java.sql.PreparedStatement __WL_stmt = null;

    int oldState = __WL_method_state;

    try {
      __WL_method_state = STATE_EJB_REMOVE;
      int __WL_num = 0;
      if (__WL_verbose) {
        Debug.say("ejbRemove " + __WL_ctx.getPrimaryKey());
      }
      super.ejbRemove();

      try {
        

        java.lang.String __WL_pk = (java.lang.String) __WL_ctx.getPrimaryKey();
        
        
        __WL_con = __WL_pm.getConnection();

        __WL_query_array[0] = "DELETE FROM T_CUSTOMER WHERE ACCOUNT = ?" ;

        if (__WL_query_array[0] != null) __WL_stmt_array[0] = __WL_con.prepareStatement(__WL_query_array[0]);

        __WL_setBeanParamsForDeleteArray(__WL_stmt_array, __WL_isModified, __WL_pk);

        for (int i = 0 ; i < 1 ; i++) {
          int j = __WL_stmt_array[i].executeUpdate();
          if (j == 0) {
             Loggable l = EJBLogger.logbeanDoesNotExistLoggable("TCustomer",__WL_pk.toString()); throw new NoSuchEntityException(l.getMessage()); 
          }
        }

        // initialize state before this instance goes back into the pool
        __WL_initialize();

          } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }

    } finally {
      __WL_method_state = oldState;
      __WL_pm.releaseArrayResources(__WL_con, __WL_stmt_array, null);
    }
}

  

  public void ejbLoad()
  {
    int oldState = __WL_method_state;
    try {
      __WL_method_state = STATE_EJBLOAD;

      __WL_initialize();

      super.ejbLoad();

    } finally {
      __WL_method_state = oldState;
    }
  }

  public void ejbStore() {    __WL_store(true);
}

  public void __WL_store(boolean unregister) 
  {
    
    java.sql.Connection __WL_con = null;
    java.sql.PreparedStatement[] __WL_stmt_array = new java.sql.PreparedStatement[1];java.sql.PreparedStatement __WL_stmt_T_CUSTOMER_0 = null;__WL_stmt_array[0] = __WL_stmt_T_CUSTOMER_0;
    int oldState = __WL_method_state;


    try {
      __WL_method_state = STATE_EJBSTORE;
      if (__WL_verbose) {
        Debug.say("ejbStore "+ __WL_ctx.getPrimaryKey());
      }
      super.ejbStore();

      try {
        int __WL_num          = 0;
        int __WL_count        = 0;
        int __WL_total       = 0;
        
        java.lang.String __WL_pk     = (java.lang.String) __WL_ctx.getPrimaryKey();
        String __WL_query     = null;
        StringBuffer sb      = new StringBuffer();
        

        
        
        __WL_count = 0;

        sb.setLength(0);if (__WL_isModified[1])  {if (__WL_count > 0) sb.append(", ");sb.append("CBALANCE = ? ");__WL_count++;}if (__WL_isModified[2])  {if (__WL_count > 0) sb.append(", ");sb.append("CNAME = ? ");__WL_count++;}if (__WL_isModified[3])  {if (__WL_count > 0) sb.append(", ");sb.append("PASSWORD = ? ");__WL_count++;}

        __WL_total = __WL_total + __WL_count + 0;

        if ( (__WL_count > 0) || (0 > 0) ) {

          __WL_con = __WL_pm.getConnection();

          if (__WL_count > 0) {
            // we have modified non-Blob/Clob Columns

            
            

            __WL_query = "UPDATE T_CUSTOMER SET " +
                        sb.toString() +
                        " WHERE ACCOUNT = ?" 
                        ;
            if(__WL_verbose) {
              Debug.say("WL_store sql: " + __WL_query);
            }

            __WL_stmt_array[0] = __WL_con.prepareStatement(__WL_query);

            __WL_setBeanParamsForUpdateArray(__WL_stmt_array, __WL_isModified, __WL_pk, 0);

            int __WL_i = __WL_stmt_array[0].executeUpdate();
            if (__WL_i == 0) {
               Loggable l = EJBLogger.logbeanDoesNotExistLoggable("TCustomer",__WL_pk.toString()); throw new NoSuchEntityException(l.getMessage()); 
            }
          }

          if (0 > 0) {
            // we have modified Blob/Clob Columns
            
          }
        }


        if (__WL_total == 0) {
          if (__WL_verbose) {
            Debug.say("ejbStore: avoided a store.  ejbStore: complete");
          }
          return;
        }

        
        for (int __WL_i = 0; __WL_i < __WL_isModified.length; __WL_i++) {
          if (__WL_isModified[__WL_i]) {
            __WL_isModified[__WL_i] = false;
            __WL_isLoaded[__WL_i] = true;
          }
        }
        if (unregister) {
              __WL_pm.unregisterModifiedBean(__WL_ctx.getPrimaryKey());

        }
        __WL_modifiedBeanIsRegistered = false;
        

        if (__WL_verbose) {
          Debug.say("ejbStore: complete");
        }
          } catch (RuntimeException re) {
      if (__WL_verbose) {
        Debug.say("rethrowing RuntimeException.");
        re.printStackTrace();
      }
      throw re;
    } catch (Exception ex) {
      if (__WL_verbose) {
        Debug.say("wrapping Exception in PersistenceRuntimeException.");
        ex.printStackTrace();
      }
      throw new PersistenceRuntimeException(ex);
    }

    } 
    finally {
      __WL_method_state = oldState;
      __WL_pm.releaseArrayResources(__WL_con, __WL_stmt_array, null);
    }
  }


  public void ejbPassivate()
  {
    int oldState = __WL_method_state;
    try {
      __WL_method_state = STATE_EJB_PASSIVATE;
      super.ejbPassivate();

      __WL_initialize();
    } finally {
      __WL_method_state = oldState;
    }
  }

  // Blob/Clob methods
  

  // end javax.ejb.EntityBean
  //=================================================================
}

⌨️ 快捷键说明

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