Package cn.org.zeronote.orm

Examples of cn.org.zeronote.orm.ORMTable


   * 生成key值
   * @param obj
   * @return
   */
  private List<String> generaCacheKey(Object obj) {
    ORMTable ormTable = obj.getClass().getAnnotation(ORMTable.class);
    if (ormTable != null) {
      String cachedTableKey = "".equalsIgnoreCase(ormTable.cachedShortAlias()) ? ormTable.tableName() : ormTable.cachedShortAlias();
      String[] cachedKeys = ormTable.cachedKey();
     
      if (cachedKeys.length > 0) {
        List<String> ks = new ArrayList<String>();
        for (int i = 0; i < cachedKeys.length; i++) {
          String cachedCol = cachedKeys[i];
View Full Code Here


    Jedis jedis = getJedis();
    if (jedis != null) {
      try {
        T t = null;
        // 先在redis里找 XXX Annotation可以cache
        ORMTable ormTable = pojoType.getAnnotation(ORMTable.class);
        String cachedTableKey = "".equalsIgnoreCase(ormTable.cachedShortAlias()) ? ormTable.tableName() : ormTable.cachedShortAlias();
       
        String[] cachedKeys = ormTable.cachedKey();
        for (String cachedKey : cachedKeys) {
          String[] ks = cachedKey.split("=");
          Object arg = args.get(ks[0]);
          if (arg != null) {
            // 存在key值,则查找,否则数据库中差
View Full Code Here

    ORMAutoAssemble ormaa = pojoClazz.getAnnotation(ORMAutoAssemble.class);
    if (ormaa == null) {
      throw new IllegalAccessException("It not a ORMAutoAssemble Class!");
    }
   
    ORMTable ormTable = pojoClazz.getAnnotation(ORMTable.class);
    if (ormTable == null) {
      throw new IllegalAccessException("It not a ORMTable Class!");
    }
   
    String tableName = ormTable.tableName();
    String[] orders = ormTable.order();
    List<Object> params = new ArrayList<Object>();
   
    this.sql = genSql(params, tableName, this.argsMap, orders);
   
    // params
View Full Code Here

    ORMAutoAssemble ormaa = pojoClazz.getAnnotation(ORMAutoAssemble.class);
    if (ormaa == null) {
      throw new IllegalAccessException("It not a ORMAutoAssemble Class!");
    }
   
    ORMTable ormTable = pojoClazz.getAnnotation(ORMTable.class);
    if (ormTable == null) {
      throw new IllegalAccessException("It not a ORMTable Class!");
    }
    ORMHash ormHashTable = pojoClazz.getAnnotation(ORMHash.class);
   
   
    String tableName = ormHashTable == null ? ormTable.tableName() : DBUtils.getInstance().getHashTableName(ormHashTable, ormTable, pojo);
    generate(tableName);
   
  }
View Full Code Here

        ORMHash ht = clz.getAnnotation(ORMHash.class);
        if (ht == null) {
          logger.warn("class[{}] not have ORMHashTable Annotation!", clz.toString());
          continue;
        }
        ORMTable table = clz.getAnnotation(ORMTable.class);
        if (table == null) {
          logger.warn("class[{}] not have ORMHashTable Annotation!", clz.toString());
          continue;
        }
        createTable(ht, table);
View Full Code Here

    ORMAutoAssemble ormaa = pojoClazz.getAnnotation(ORMAutoAssemble.class);
    if (ormaa == null) {
      throw new IllegalAccessException("It not a ORMAutoAssemble Class!");
    }
   
    ORMTable ormTable = pojoClazz.getAnnotation(ORMTable.class);
    if (ormTable == null) {
      throw new IllegalAccessException("It not a ORMTable Class!");
    }
   
    ORMHash ormHashTable = pojoClazz.getAnnotation(ORMHash.class);
   
    String tableName = null;
    if (ormHashTable == null) {
      tableName = ormTable.tableName();
    } else {
      String hashKey = this.pojoClazz.getDeclaredField(ormHashTable.hashRefColumn()).getName();
      long hashCol = Long.valueOf(String.valueOf(this.delArgs.get(hashKey)));
      tableName = DBUtils.getInstance().findHashTableName(ormHashTable, ormTable, hashCol);
    }
View Full Code Here

    ORMAutoAssemble ormaa = pojoClazz.getAnnotation(ORMAutoAssemble.class);
    if (ormaa == null) {
      throw new IllegalAccessException("It not a ORMAutoAssemble Class!");
    }
   
    ORMTable ormTable = pojoClazz.getAnnotation(ORMTable.class);
    if (ormTable == null) {
      throw new IllegalAccessException("It not a ORMTable Class!");
    }
    ORMHash ormHashTable = pojoClazz.getAnnotation(ORMHash.class);
   
    String refCol = ormHashTable.hashRefColumn();

    Map<String, Map<String, List<Object>>> tableArgsMap = new HashMap<String, Map<String,List<Object>>>();
    // 装填 散列列
    for (String colKey : argsMap.keySet()) {
      if (colKey.equals(refCol)) {
        // 参照列拆分
        Object[] args = argsMap.get(colKey);
        for (Object colValue : args) {
          String tableName = DBUtils.getInstance().findHashTableName(ormHashTable, ormTable, Long.valueOf(String.valueOf(colValue)));
          if (tableArgsMap.get(tableName) == null) {
            Map<String, List<Object>> m = new HashMap<String, List<Object>>();
            List<Object> l = new ArrayList<Object>();
            l.add(colValue);
            m.put(colKey, l);
            tableArgsMap.put(tableName, m);
          } else {
            tableArgsMap.get(tableName).get(colKey).add(colValue);
          }
        }
        break;
      }
    }
    // 装填其它参数
    for (String colKey : argsMap.keySet()) {
      if (colKey.equals(refCol)) {
        // 这个参数已经拆分完毕
        continue;
      }
      for (Map<String, List<Object>> map : tableArgsMap.values()) {
        map.put(colKey, Arrays.asList(argsMap.get(colKey)));
      }
    }
   
    String[] orders = ormTable.order();
   
    this.sqls = new ArrayList<String>();
    this.argsObjs = new ArrayList<Object[]>();
    for (String tableName : tableArgsMap.keySet()) {
      List<Object> params = new ArrayList<Object>();
View Full Code Here

    ORMAutoAssemble ormaa = pojoClazz.getAnnotation(ORMAutoAssemble.class);
    if (ormaa == null) {
      throw new IllegalAccessException("It not a ORMAutoAssemble Class!");
    }
   
    ORMTable ormTable = pojoClazz.getAnnotation(ORMTable.class);
    if (ormTable == null) {
      throw new IllegalAccessException("It not a ORMTable Class!");
    }
    ORMHash ormHashTable = pojoClazz.getAnnotation(ORMHash.class);
   
   
    String tableName = ormHashTable == null ? ormTable.tableName() : DBUtils.getInstance().getHashTableName(ormHashTable, ormTable, pojo);
    generate(tableName);
  }
View Full Code Here

    ORMAutoAssemble ormaa = pojoClazz.getAnnotation(ORMAutoAssemble.class);
    if (ormaa == null) {
      throw new IllegalAccessException("It not a ORMAutoAssemble Class!");
    }
   
    ORMTable ormTable = pojoClazz.getAnnotation(ORMTable.class);
    if (ormTable == null) {
      throw new IllegalAccessException("It not a ORMTable Class!");
    }
    ORMHash ormHashTable = pojoClazz.getAnnotation(ORMHash.class);
   
   
    String tableName = ormHashTable == null ? ormTable.tableName() : DBUtils.getInstance().getHashTableName(ormHashTable, ormTable, pojo);
    generate(tableName);
   
  }
View Full Code Here

        ORMHash ht = clz.getAnnotation(ORMHash.class);
        if (ht == null) {
          logger.warn("class[{}] not have ORMHashTable Annotation!", clz.toString());
          continue;
        }
        ORMTable table = clz.getAnnotation(ORMTable.class);
        if (table == null) {
          logger.warn("class[{}] not have ORMHashTable Annotation!", clz.toString());
          continue;
        }
        createTable(ht, table);
View Full Code Here

TOP

Related Classes of cn.org.zeronote.orm.ORMTable

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.