net.java.ao.Query.toSQL()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中net.java.ao.Query.toSQL方法的一些代码示例,展示了Query.toSQL的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.toSQL方法的具体详情如下:
包路径:net.java.ao.Query
类名称:Query
方法名:toSQL

Query.toSQL介绍

暂无

代码示例

代码示例来源:origin: net.java.dev.activeobjects/activeobjects-core

/**
 * Counts all entities of the specified type matching the given {@link Query} instance.  The SQL runs as a
 * <code>SELECT COUNT(*)</code> to ensure maximum performance.
 *
 * @param type  The type of the entities which should be counted.
 * @param query The {@link Query} instance used to determine the result set which will be counted.
 * @return The number of entities of the given type which match the specified query.
 */
public <K> int count(Class<? extends RawEntity<K>> type, Query query) throws SQLException {
  EntityInfo entityInfo = resolveEntityInfo(type);
  Connection connection = null;
  PreparedStatement stmt = null;
  ResultSet res = null;
  try {
    connection = provider.getConnection();
    final String sql = query.toSQL(entityInfo, provider, getTableNameConverter(), true);
    stmt = provider.preparedStatement(connection, sql);
    provider.setQueryStatementProperties(stmt, query);
    query.setParameters(this, stmt);
    res = stmt.executeQuery();
    return res.next() ? res.getInt(1) : -1;
  } finally {
    closeQuietly(res);
    closeQuietly(stmt);
    closeQuietly(connection);
  }
}

代码示例来源:origin: net.java.dev.activeobjects/activeobjects

/**
 * Counts all entities of the specified type matching the given {@link Query} instance.  The SQL runs as a
 * <code>SELECT COUNT(*)</code> to ensure maximum performance.
 *
 * @param type  The type of the entities which should be counted.
 * @param query The {@link Query} instance used to determine the result set which will be counted.
 * @return The number of entities of the given type which match the specified query.
 */
public <K> int count(Class<? extends RawEntity<K>> type, Query query) throws SQLException {
  EntityInfo entityInfo = resolveEntityInfo(type);
  Connection connection = null;
  PreparedStatement stmt = null;
  ResultSet res = null;
  try {
    connection = provider.getConnection();
    final String sql = query.toSQL(entityInfo, provider, getTableNameConverter(), true);
    stmt = provider.preparedStatement(connection, sql);
    provider.setQueryStatementProperties(stmt, query);
    query.setParameters(this, stmt);
    res = stmt.executeQuery();
    return res.next() ? res.getInt(1) : -1;
  } finally {
    closeQuietly(res);
    closeQuietly(stmt);
    closeQuietly(connection);
  }
}

代码示例来源:origin: net.java.dev.activeobjects/activeobjects

try {
  conn = provider.getConnection();
  final String sql = query.toSQL(entityInfo, provider, getTableNameConverter(), false);

代码示例来源:origin: net.java.dev.activeobjects/activeobjects-core

try {
  conn = provider.getConnection();
  final String sql = query.toSQL(entityInfo, provider, getTableNameConverter(), false);

代码示例来源:origin: net.java.dev.activeobjects/activeobjects

try {
  conn = provider.getConnection();
  final String sql = query.toSQL(entityInfo, provider, getTableNameConverter(), false);

代码示例来源:origin: net.java.dev.activeobjects/activeobjects-core

try {
  conn = provider.getConnection();
  final String sql = query.toSQL(entityInfo, provider, getTableNameConverter(), false);

相关文章