本文整理汇总了Java中org.skife.jdbi.v2.TransactionIsolationLevel类的典型用法代码示例。如果您正苦于以下问题:Java TransactionIsolationLevel类的具体用法?Java TransactionIsolationLevel怎么用?Java TransactionIsolationLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionIsolationLevel类属于org.skife.jdbi.v2包,在下文中一共展示了TransactionIsolationLevel类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: append
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@Override
public void append(final UUID id, final UnitOfWork uow) {
final String sql = String.format("insert into %s (id, uow_data, version) values (:id, :uow_data, :version)", tables.getUnitOfWorkTable());
log.debug(sql);
final String asString = toStringFunction.apply(uow);
dbi.inTransaction(TransactionIsolationLevel.READ_COMMITTED, new TransactionCallback<Integer>() {
@Override
public Integer inTransaction(Handle conn, TransactionStatus status)
throws Exception {
conn.createStatement(sql)
.bind("id", id.toString())
.bind("uow_data", asString)
.bind("version", uow.getVersion())
.execute();
return null;
}
}) ;
log.debug("wrote uow");
}
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:25,代码来源:JdbiUnitOfWorkAutoCommitJournalDao.java
示例2: load
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@Override
public String load(final Long id) {
String result = null;
try {
log.info("will load {} from table {}", id.toString(), tableName);
result = dbi.inTransaction(TransactionIsolationLevel.READ_COMMITTED,
new TransactionCallback<String>() {
@Override
public String inTransaction(Handle h, TransactionStatus ts) throws Exception {
String sql = String.format("select value from %s where id = :id", tableName);
return h.createQuery(sql).bind("id", id).map(ClobToStringMapper.FIRST).first();
}
});
if (result==null) {
log.warn("found a null value for id {}", id.toString());
} else {
log.info("loaded {} {} from table {}", id.toString(), result, tableName);
}
} catch (Exception e) {
log.error("error when loading {} from table {}", id.toString(), tableName);
e.printStackTrace();
}
return result;
}
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:25,代码来源:HzStringQueueStore.java
示例3: load
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@Override
public String load(final UUID id) {
String result = null;
try {
log.debug("will load {} from table {}", id.toString(), tableName);
result = dbi.inTransaction(TransactionIsolationLevel.READ_COMMITTED,
new TransactionCallback<String>() {
@Override
public String inTransaction(Handle h, TransactionStatus ts) throws Exception {
String sql = String.format("select aggregate_root_data from %s where id = :id", tableName);
return h.createQuery(sql).bind("id", id.toString()).map(ClobToStringMapper.FIRST).first();
}
});
// http://stackoverflow.com/questions/9779324/program-hangs-after-retrieving-100-rows-containg-clob
if (result == null) {
log.debug("found a null or zero length value for id {}", id.toString());
} else {
log.debug("loaded {} {} from table {}", id.toString(), result.replace("\n", "").substring(0, Math.min(10, result.length()-1)), tableName);
}
} catch (Exception e) {
log.error("error when loading {} from table {}", id.toString(), tableName);
e.printStackTrace();
} finally {
}
return result;
}
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:27,代码来源:HzStringMapStore.java
示例4: useTransaction
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
public static void useTransaction(DBI dbi, Consumer<Handle> callback) {
try {
dbi.useTransaction(TransactionIsolationLevel.SERIALIZABLE, (handle, status) -> callback.accept(handle));
} catch (CallbackFailedException e) {
throw Throwables.propagate(e.getCause());
}
}
开发者ID:openregister,项目名称:openregister-java,代码行数:8,代码来源:RegisterContext.java
示例5: inTransaction
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
public static <T> T inTransaction(DBI dbi, Function<Handle, T> callbackFn) {
try {
return dbi.inTransaction(TransactionIsolationLevel.SERIALIZABLE, (handle, status) -> callbackFn.apply(handle));
} catch (CallbackFailedException e) {
throw Throwables.propagate(e.getCause());
}
}
开发者ID:openregister,项目名称:openregister-java,代码行数:8,代码来源:RegisterContext.java
示例6: append
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@Override
public void append(final K targetId, final Command command, final UnitOfWork unitOfWork) {
checkNotNull(targetId);
checkNotNull(command);
checkNotNull(unitOfWork);
checkArgument(unitOfWork.getCommandId().equals(command.getCommandId()));
String insertUowSql = String.format("insert into %s (id, uow_data, version, inserted_on) values (:id, :uow_data, :version, :inserted_on)", dbMetadata.unitOfWorkTable);
String insertCommandSql = String.format("insert into %s (id, cmd_data) values (:id, :cmd_data)", dbMetadata.commandTable);
logger.debug(insertUowSql);
logger.debug("appending uow to {} with id {}", dbMetadata.aggregateRootTable, targetId);
try {
dbi.inTransaction(TransactionIsolationLevel.READ_COMMITTED, (conn, status) -> {
int result1 = conn.createStatement(insertUowSql)
.bind("id", targetId.toString())
.bind("uow_data", uowSer.toStringFunction.apply(unitOfWork))
.bind("version", unitOfWork.getVersion())
.bind("inserted_on", unitOfWork.getCreatedOn())
.execute() ;
int result2 = conn.createStatement(insertCommandSql)
.bind("id", command.getCommandId().toString())
.bind("cmd_data", cmdSer.toStringFunction.apply(command))
.execute() ;
return result1 + result2 == 2;
}
);
} catch (Exception e) {
CommandExecutionException exception = convertFrom(e);
logger.error(exception.getMessage());
throw exception;
}
}
开发者ID:rodolfodpk,项目名称:myeslib2,代码行数:38,代码来源:Stack1JdbiDao.java
示例7: executeInTransaction
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
public void executeInTransaction(final Transaction<Void, BusinessAnalyticsSqlDao> transaction) {
// In REPEATABLE READ, every lock acquired during a transaction is held for the duration of the transaction.
// In READ COMMITTED the locks that did not match the scan are released after the STATEMENT completes.
// We need to make sure to use READ COMMITTED here, to avoid MySQL deadlocks under high load. This should
// not have any impact in these transactions as we only delete & re-insert rows on a per account basis,
// and accounts are not updated in parallel (not enforced, but we try hard not to).
sqlDao.inTransaction(TransactionIsolationLevel.READ_COMMITTED, transaction);
}
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:9,代码来源:BusinessAnalyticsDaoBase.java
示例8: findEnabledUsersWithRolesAndPermissions
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@SqlQuery(EnabledUserRolesPermissionsBaseSelectPrefix + "users.username = :username")
@MapResultAsBean
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
protected abstract Iterator<UserRolePermissionJoinRow> findEnabledUsersWithRolesAndPermissions(@Bind("username") String username);
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:5,代码来源:DefaultJdbiUserSecurityDAO.java
示例9: findUsersWithRolesAndPermissions
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@SqlQuery(UserRolesPermissionsBaseSelectPrefix + "users.username = :username")
@MapResultAsBean
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
protected abstract Iterator<UserRolePermissionJoinRow> findUsersWithRolesAndPermissions(@Bind("username") String username);
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:5,代码来源:DefaultJdbiUserSecurityDAO.java
示例10: findEnabledUsersWithoutRoles
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@SqlQuery("SELECT user_Id AS id, username, password FROM users WHERE enabled AND username = :username")
@MapResultAsBean
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
protected abstract Iterator<DefaultUserImpl> findEnabledUsersWithoutRoles(@Bind("username") String username);
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:5,代码来源:DefaultJdbiUserSecurityDAO.java
示例11: findUsersWithoutRoles
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@SqlQuery("SELECT user_Id AS id, username, password FROM users WHERE username = :username")
@MapResultAsBean
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
protected abstract Iterator<DefaultUserImpl> findUsersWithoutRoles(@Bind("username") String username);
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:5,代码来源:DefaultJdbiUserSecurityDAO.java
示例12: getEnabledUserRolesAndPermissions
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@SqlQuery(EnabledRolesPermissionsBaseSelectPrefix + "users_roles.user_id = :userId")
@MapResultAsBean
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
protected abstract Iterator<UserRolePermissionJoinRow> getEnabledUserRolesAndPermissions(@Bind("userId") Long userId);
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:5,代码来源:DefaultJdbiUserSecurityDAO.java
示例13: getUserRolesAndPermissions
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@SqlQuery(RolesPermissionsBaseSelectPrefix + "users_roles.user_id = :userId")
@MapResultAsBean
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
protected abstract Iterator<UserRolePermissionJoinRow> getUserRolesAndPermissions(@Bind("userId") Long userId);
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:5,代码来源:DefaultJdbiUserSecurityDAO.java
示例14: getUser
import org.skife.jdbi.v2.TransactionIsolationLevel; //导入依赖的package包/类
@Override
@Transaction(value = TransactionIsolationLevel.READ_COMMITTED)
public DefaultUserImpl getUser(Long userId) {
checkArgument(userId != null, "getUser() requires a non-null userId parameter.");
return extractObjectGraphFromJoinResults(getUserWithRolesAndPermissions(userId));
}
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:7,代码来源:DefaultJdbiUserDAO.java
注:本文中的org.skife.jdbi.v2.TransactionIsolationLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论