com.jfinal.plugin.activerecord.Config Java Examples
The following examples show how to use
com.jfinal.plugin.activerecord.Config.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JFinalTxAop.java From sdb-mall with Apache License 2.0 | 6 votes |
/** * 获取配置的TxConfig,可注解到class或者方法上 * @param pjp * @return Config */ public static Config getConfigWithTxConfig(ProceedingJoinPoint pjp) { MethodSignature ms = (MethodSignature) pjp.getSignature(); Method method = ms.getMethod(); TxConfig txConfig = method.getAnnotation(TxConfig.class); if (txConfig == null) txConfig = pjp.getTarget().getClass().getAnnotation(TxConfig.class); if (txConfig != null) { Config config = DbKit.getConfig(txConfig.value()); if (config == null) throw new RuntimeException("Config not found with TxConfig: " + txConfig.value()); return config; } return null; }
Example #2
Source File: JfinalTransactionInterceptor.java From snakerflow with Apache License 2.0 | 6 votes |
protected TransactionStatus getTransaction() { try { boolean isNew = false; Config config = JfinalHelper.getConfig(); Connection conn = config.getThreadLocalConnection(); if(conn == null) { conn = config.getConnection(); config.setThreadLocalConnection(conn); conn.setAutoCommit(false); isNew = true; } return new TransactionStatus(conn, isNew); } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } }
Example #3
Source File: SqlDebugger.java From jboot with Apache License 2.0 | 5 votes |
public static void debug(Config config, String sql, Object... paras) { if (!printer.isPrint(config, sql, paras)) { return; } if (paras != null) { for (Object value : paras) { // null if (value == null) { sql = sql.replaceFirst("\\?", "null"); } // number else if (value instanceof Number) { sql = sql.replaceFirst("\\?", value.toString()); } // numeric else if (value instanceof String && StrUtil.isNumeric((String) value)) { sql = sql.replaceFirst("\\?", (String) value); } // other else { StringBuilder sb = new StringBuilder(); sb.append("'"); if (value instanceof Date) { sb.append(DateKit.toStr((Date) value, DateKit.timeStampPattern)); } else { sb.append(value.toString()); } sb.append("'"); sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(sb.toString())); } } } printer.print(sql); }
Example #4
Source File: JfinalHelper.java From snakerflow with Apache License 2.0 | 5 votes |
public static Config getConfig() { if(config == null) { synchronized (JfinalHelper.class) { if(config == null) { if(StringHelper.isNotEmpty(configName)) { config = DbKit.getConfig(configName); } if(config == null) { config = DbKit.getConfig(); } } } } return config; }
Example #5
Source File: JfinalAccess.java From snakerflow with Apache License 2.0 | 5 votes |
/** * 从jfinal的threadlocal中获取数据库连接 */ protected Connection getConnection() throws SQLException { Config config = JfinalHelper.getConfig(); Connection conn = config.getThreadLocalConnection(); if(conn == null) { conn = config.getConnection(); conn.setAutoCommit(true); } return conn; }
Example #6
Source File: SqlDebugger.java From jboot with Apache License 2.0 | 4 votes |
@Override public boolean isPrint(Config config, String sql, Object... paras) { return Jboot.isDevMode(); }
Example #7
Source File: JfinalTransactionInterceptor.java From snakerflow with Apache License 2.0 | 4 votes |
protected void commit(TransactionStatus status) { super.commit(status); Config config = JfinalHelper.getConfig(); config.removeThreadLocalConnection(); }
Example #8
Source File: JfinalTransactionInterceptor.java From snakerflow with Apache License 2.0 | 4 votes |
protected void rollback(TransactionStatus status) { super.rollback(status); Config config = JfinalHelper.getConfig(); config.removeThreadLocalConnection(); }
Example #9
Source File: JFinalTxAop.java From sdb-mall with Apache License 2.0 | 2 votes |
/** * 获取配置的事务级别 * @param config * @return */ protected int getTransactionLevel(Config config) { return config.getTransactionLevel(); }
Example #10
Source File: SqlDebugger.java From jboot with Apache License 2.0 | votes |
public boolean isPrint(Config config, String sql, Object... paras);