• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GenericRowMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.j256.ormlite.stmt.GenericRowMapper的典型用法代码示例。如果您正苦于以下问题:Java GenericRowMapper类的具体用法?Java GenericRowMapper怎么用?Java GenericRowMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GenericRowMapper类属于com.j256.ormlite.stmt包,在下文中一共展示了GenericRowMapper类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testQueryForOneReleaseConnection

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Test
public void testQueryForOneReleaseConnection() throws Exception {
	Connection connection = createMock(Connection.class);
	PreparedStatement prepStmt = createMock(PreparedStatement.class);
	GeneratedKeyHolder keyHolder = createMock(GeneratedKeyHolder.class);
	ResultSet resultSet = createMock(ResultSet.class);
	@SuppressWarnings("unchecked")
	GenericRowMapper<Foo> rowMapper = createMock(GenericRowMapper.class);

	JdbcDatabaseConnection jdc = new JdbcDatabaseConnection(connection);
	String statement = "statement";
	expect(connection.prepareStatement(statement, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
			.andReturn(prepStmt);
	expect(prepStmt.executeQuery()).andReturn(resultSet);
	expect(resultSet.getMetaData()).andReturn(null);
	expect(resultSet.next()).andReturn(false);
	resultSet.close();
	expect(prepStmt.getMoreResults()).andReturn(false);
	// should close the statement
	prepStmt.close();
	connection.close();
	replay(connection, prepStmt, keyHolder, resultSet, rowMapper);
	jdc.queryForOne(statement, new Object[0], new FieldType[0], rowMapper, null);
	jdc.close();
	verify(connection, prepStmt, keyHolder, resultSet, rowMapper);
}
 
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:27,代码来源:JdbcDatabaseConnectionTest.java


示例2: queryForOne

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Override
public <T> Object queryForOne(String statement, Object[] args, FieldType[] argFieldTypes,
		GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException {
	PreparedStatement stmt =
			connection.prepareStatement(statement, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
	if (args != null) {
		statementSetArgs(stmt, args, argFieldTypes);
	}
	DatabaseResults results = new H2DatabaseResults(stmt.executeQuery(), objectCache, true);
	if (!results.next()) {
		// no results at all
		IOUtils.closeThrowSqlException(results, "results");
		return null;
	}
	T first = rowMapper.mapRow(results);
	if (results.next()) {
		return MORE_THAN_ONE;
	} else {
		return first;
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:22,代码来源:H2DatabaseConnection.java


示例3: rxGetSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Override
public Observable<GenericRowMapper<DataType>> rxGetSelectStarRowMapper() {
    final Func0<Observable<GenericRowMapper<DataType>>> loFunc = () -> {
        try {
            return Observable.just(getSelectStarRowMapper());
        } catch (SQLException e) {
            return Observable.error(e);
        }
    };
    return Observable.defer(loFunc);
}
 
开发者ID:RoRoche,项目名称:AndroidStarter,代码行数:12,代码来源:RxBaseDaoImpl.java


示例4: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
public GenericRowMapper<T> getSelectStarRowMapper()
{
  try
  {
    GenericRowMapper localGenericRowMapper = this.dao.getSelectStarRowMapper();
    return localGenericRowMapper;
  }
  catch (SQLException localSQLException)
  {
    logMessage(localSQLException, "getSelectStarRowMapper threw exception");
    throw new RuntimeException(localSQLException);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:14,代码来源:RuntimeExceptionDao.java


示例5: queryForOne

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
public <T> Object queryForOne(String paramString, Object[] paramArrayOfObject, FieldType[] paramArrayOfFieldType, GenericRowMapper<T> paramGenericRowMapper, ObjectCache paramObjectCache)
{
  Cursor localCursor = null;
  try
  {
    localCursor = this.db.rawQuery(paramString, toStrings(paramArrayOfObject));
    AndroidDatabaseResults localAndroidDatabaseResults = new AndroidDatabaseResults(localCursor, paramObjectCache);
    logger.trace("{}: queried for one result: {}", this, paramString);
    if (!localAndroidDatabaseResults.first())
      return null;
    Object localObject2 = paramGenericRowMapper.mapRow(localAndroidDatabaseResults);
    if (localAndroidDatabaseResults.next())
    {
      Object localObject3 = MORE_THAN_ONE;
      return localObject3;
    }
    return localObject2;
  }
  catch (android.database.SQLException localSQLException)
  {
    throw SqlExceptionUtil.create("queryForOne from database failed: " + paramString, localSQLException);
  }
  finally
  {
    if (localCursor != null)
      localCursor.close();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:29,代码来源:AndroidDatabaseConnection.java


示例6: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
/**
 * @see Dao#getSelectStarRowMapper()
 */
@Override
public GenericRowMapper<T> getSelectStarRowMapper() {
	try {
		return dao.getSelectStarRowMapper();
	} catch (SQLException e) {
		logMessage(e, "getSelectStarRowMapper threw exception");
		throw new RuntimeException(e);
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:13,代码来源:RuntimeExceptionDao.java


示例7: queryForOne

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Override
public <T> Object queryForOne(String statement, Object[] args, FieldType[] argfieldTypes,
		GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException {
	if (proxy == null) {
		return null;
	} else {
		return proxy.queryForOne(statement, args, argfieldTypes, rowMapper, objectCache);
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:10,代码来源:DatabaseConnectionProxy.java


示例8: testForeignAutoRefresh

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testForeignAutoRefresh() throws Exception {
	Field field = ForeignAutoRefresh.class.getDeclaredField("foreign");
	ConnectionSource connectionSource = createMock(ConnectionSource.class);
	DatabaseConnection connection = createMock(DatabaseConnection.class);
	expect(connectionSource.getDatabaseType()).andReturn(databaseType).anyTimes();
	expect(connectionSource.getReadOnlyConnection("ForeignAutoRefresh")).andReturn(connection);
	ForeignForeign foreignForeign = new ForeignForeign();
	String stuff = "21312j3213";
	int id = 4123123;
	foreignForeign.id = id;
	foreignForeign.stuff = stuff;
	expect(connection.queryForOne(isA(String.class), isA(Object[].class), isA(FieldType[].class),
			isA(GenericRowMapper.class), (ObjectCache) isNull())).andReturn(foreignForeign);
	connectionSource.releaseConnection(connection);
	DatabaseResults results = createMock(DatabaseResults.class);
	ForeignAutoRefresh foreign = new ForeignAutoRefresh();
	replay(results, connectionSource, connection);
	FieldType fieldType = FieldType.createFieldType(connectionSource, ForeignAutoRefresh.class.getSimpleName(),
			field, ForeignAutoRefresh.class);
	fieldType.configDaoInformation(connectionSource, ForeignAutoRefresh.class);
	assertNull(foreign.foreign);
	fieldType.assignField(foreign, id, false, null);
	assertNotNull(foreign.foreign);
	assertEquals(id, foreign.foreign.id);
	assertEquals(stuff, foreign.foreign.stuff);
	verify(results, connectionSource, connection);
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:30,代码来源:FieldTypeTest.java


示例9: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
public GenericRowMapper<T> getSelectStarRowMapper()
{
  return this.statementExecutor.getSelectStarRowMapper();
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:BaseDaoImpl.java


示例10: queryForOne

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Override
public <T> Object queryForOne(String statement, Object[] args, FieldType[] argFieldTypes,
		GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException {
	return queryForOne(statement, args, argFieldTypes, rowMapper, objectCache, "query for one");
}
 
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:6,代码来源:JdbcDatabaseConnection.java


示例11: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Override
public GenericRowMapper<T> getSelectStarRowMapper() throws SQLException {
    return dao.getSelectStarRowMapper();
}
 
开发者ID:citiususc,项目名称:calendula,代码行数:5,代码来源:GenericDao.java


示例12: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
@Override
public GenericRowMapper<T> getSelectStarRowMapper() throws SQLException {
	return statementExecutor.getSelectStarRowMapper();
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:5,代码来源:BaseDaoImpl.java


示例13: rxGetSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
/**
 * Return a row mapper that is suitable for mapping results from a rxQuery to select * (star).
 */
Observable<GenericRowMapper<T>> rxGetSelectStarRowMapper();
 
开发者ID:RoRoche,项目名称:AndroidStarter,代码行数:5,代码来源:IRxDao.java


示例14: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
/**
 * Return a row mapper that is suitable for mapping results from a query to select * (star).
 */
public GenericRowMapper<T> getSelectStarRowMapper() throws SQLException;
 
开发者ID:j256,项目名称:ormlite-core,代码行数:5,代码来源:Dao.java


示例15: queryForOne

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
/**
 * Perform a SQL query with the associated SQL statement, arguments, and types and returns a single result.
 * 
 * @param statement
 *            SQL statement to use for deleting.
 * @param args
 *            Object arguments for the SQL '?'s.
 * @param argfieldTypes
 *            Field types of the arguments.
 * @param rowMapper
 *            The mapper to use to convert the row into the returned object.
 * @param objectCache
 *            Any object cache associated with the query or null if none.
 * @return The first data item returned by the query which can be cast to T, null if none, the object
 *         {@link #MORE_THAN_ONE} if more than one result was found.
 */
public <T> Object queryForOne(String statement, Object[] args, FieldType[] argfieldTypes,
		GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException;
 
开发者ID:j256,项目名称:ormlite-core,代码行数:19,代码来源:DatabaseConnection.java


示例16: getSelectStarRowMapper

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
public abstract GenericRowMapper<T> getSelectStarRowMapper(); 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:2,代码来源:Dao.java


示例17: queryForOne

import com.j256.ormlite.stmt.GenericRowMapper; //导入依赖的package包/类
public abstract <T> Object queryForOne(String paramString, Object[] paramArrayOfObject, FieldType[] paramArrayOfFieldType, GenericRowMapper<T> paramGenericRowMapper, ObjectCache paramObjectCache); 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:2,代码来源:DatabaseConnection.java



注:本文中的com.j256.ormlite.stmt.GenericRowMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Constants类代码示例发布时间:2022-05-22
下一篇:
Java WebPanel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap