Exemplo n.º 1
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 public boolean start() {
   try {
     List<Class> modelClasses = ClassSearcher.findClasses(Model.class);
     TableBind tb = null;
     for (Class modelClass : modelClasses) {
       tb = (TableBind) modelClass.getAnnotation(TableBind.class);
       if (tb == null) {
         this.addMapping(tableName(modelClass), modelClass);
       } else {
         if (StringKit.notBlank(tb.name())) {
           if (StringKit.notBlank(tb.pk())) {
             this.addMapping(tb.name(), tb.pk(), modelClass);
           } else {
             this.addMapping(tb.name(), modelClass);
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     //			throw new RuntimeException(e);
   }
   return super.start();
 }
Exemplo n.º 2
0
 @Override
 public void commentForTables(Table table, Connection connection) {
   try {
     String sql = "SHOW TABLE STATUS ";
     pstmt = connection.prepareStatement(sql);
     rs = pstmt.executeQuery();
     table.setComment(table.getName());
     while (rs.next()) {
       if (table.getName().equals(rs.getString("name"))) {
         String comment = rs.getString("comment");
         if (StringKit.notBlank(comment)) {
           table.setComment(rs.getString("comment"));
         }
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 3
0
 @Override
 public void commentForTables(Table table, Connection connection) {
   try {
     String sql = "select table_name,comments from user_tab_comments  where table_name=?";
     pstmt = connection.prepareStatement(sql);
     rs = pstmt.executeQuery();
     table.setComment(table.getName());
     while (rs.next()) {
       if (table.getName().equals(rs.getString("table_name"))) {
         String comment = rs.getString("comments");
         if (StringKit.notBlank(comment)) {
           table.setComment(comment);
         }
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 4
0
 @Override
 public void commentForColumns(Table table, Connection connection) {
   try {
     String sql = "show full columns from" + " " + table.getName();
     pstmt = connection.prepareStatement(sql);
     rs = pstmt.executeQuery();
     Map<String, String> val = new HashMap<String, String>();
     while (rs.next()) {
       val.put(rs.getString("Field"), rs.getString("COMMENT"));
     }
     List<Column> columns = table.getColumns();
     for (Column column : columns) {
       column.setComment(column.getName());
       String comment = val.get(column.getName());
       if (StringKit.notBlank(comment)) {
         column.setComment(comment);
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 5
0
 @Override
 public void commentForColumns(Table table, Connection connection) {
   try {
     String sql = "select * from user_col_comments where TABLE_NAME = ?";
     pstmt = connection.prepareStatement(sql);
     pstmt.setString(1, table.getName());
     rs = pstmt.executeQuery();
     List<Column> columns = table.getColumns();
     for (Column column : columns) {
       column.setComment(column.getName());
       while (rs.next()) {
         if (column.getName().equals(rs.getString("COLUMN_NAME"))) {
           String comment = rs.getString("COMMENTS");
           if (StringKit.notBlank(comment)) {
             column.setComment(comment);
             continue;
           }
         }
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }