protected T findById(final ID id, final boolean removed, final Boolean lock) {
final StringBuilder sql = new StringBuilder(_selectByIdSql);
if (!removed && _removed != null) {
sql.append(" AND ").append(_removed.first());
}
if (lock != null) {
sql.append(lock ? FOR_UPDATE_CLAUSE : SHARE_MODE_CLAUSE);
}
final TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql.toString());
if (_idField.getAnnotation(EmbeddedId.class) == null) {
prepareAttribute(1, pstmt, _idAttributes.get(_table)[0], id);
}
final ResultSet rs = pstmt.executeQuery();
return rs.next() ? toEntityBean(rs, true) : null;
} catch (final SQLException e) {
throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
}
}
GenericDaoBase.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:cosmic
作者:
评论列表
文章目录