Package org.eweb4j.orm.jdbc.transaction

Examples of org.eweb4j.orm.jdbc.transaction.Trans


  // 测试事务
  public String testTrans(Pet _pet) {
    String error = null;

    // 事务模板
    Transaction.execute(new Trans() {
      @Override
      public void run(Object... args) throws Exception {
        // some eweb4j dao
      }
    }, 1, 2);
View Full Code Here


    // 无参数运行方法
    if (paramTypes == null || paramTypes.length == 0) {
      // 无参数运行方法
      if (isTrans)
        Transaction.execute(new Trans() {
          @Override
          public void run(Object... args) throws Exception {
            retn = method.invoke(actionObject);
          }
        }, "");
      else
        retn = method.invoke(actionObject);
    } else {
     
      Annotation[][] paramAnns = method.getParameterAnnotations();
      // 拿到方法所需要的参数
      final Object[] params = assemParams(paramTypes, paramAnns);

      // 带参数运行方法
      if (isTrans)
        Transaction.execute(new Trans() {
          @Override
          public void run(Object... args) throws Exception {
            retn = method.invoke(actionObject, params);
          }
        }, "");
View Full Code Here

    if (this.fields == null || this.fields.size() == 0)
      return;

    final Class<?> ownClass = ru.getObject().getClass();

    Transaction.execute(new Trans() {

      @Override
      public void run(Object... args) throws Exception {
        if (idVal == null || "0".equals(idVal) || "".equals(idVal)) {
          Object _idVal = DAOFactory.getInsertDAO(dsName).insert(t);
View Full Code Here

  public void delete() throws DAOException {
    if (this.fields == null || this.fields.size() == 0)
      return;

    final Class<?> ownClass = ru.getObject().getClass();
    Transaction.execute(new Trans() {

      @Override
      public void run(Object... args) throws Exception {
        String referencedField = idField;
        Object referencedFieldVal = idVal;
View Full Code Here

      // 检查一下当前对象的ID是否存在于数据库
      return;
    }
   
    try{
      Transaction.execute(new Trans() {
        @Override
        public void run(Object... args) throws Exception {
          Class<?> ownClass = ru.getObject().getClass();
   
          // "update {table} set {idCol} = {newIdVal} where {idCol} = {idVal}
View Full Code Here

    }
  }

  @Test
  public void testMap() {
    Transaction.execute(new Trans() {

      @Override
      public void run(Object... args) throws Exception {
        Pet pet = Pet.inst.find().first();
        Map<String, Object> map = new HashMap<String, Object>();
View Full Code Here

      e.printStackTrace();
    }
  }

  public static void testOneUpdate() {
    Transaction.execute(new Trans() {
     
      @Override
      public void run(Object... args) throws Exception {
        Master master = new Master();
        master.setId(1L);
View Full Code Here

   */
  public void insert() throws DAOException {
    if (this.fields == null || this.fields.size() == 0)
      return;
   
    Transaction.execute(new Trans() {
      @Override
      public void run(Object... args) throws Exception {
        // "insert into {relTable}({from},{to}) values({idVal},{toVal})"
        // 插入关系表
        String format = "INSERT INTO %s(%s,%s) VALUES(?,?) ";
View Full Code Here

      try {
        // "update {table} set {idCol} = {newIdVal} where {idCol} = {idVal}
        // ; update {relTable} set {fromCol} = {newIdVal} where {fromCol} = {idVal}"
        final String sql1 = String.format(format, table, idColumn, newIdVal, idColumn, idVal);
        final String sql2 = String.format(format, relTable, from, newIdVal, from, idVal);
        Transaction.execute(new Trans() {
         
          @Override
          public void run(Object... args) throws Exception {
            DAOFactory.getUpdateDAO(dsName).updateBySQL(sql1);
            DAOFactory.getUpdateDAO(dsName).updateBySQL(sql2);           
View Full Code Here

TOP

Related Classes of org.eweb4j.orm.jdbc.transaction.Trans

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.