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

Java ObjectCache类代码示例

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

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



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

示例1: updateRows

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
private static <T, ID> int updateRows(DatabaseConnection paramDatabaseConnection, Class<T> paramClass, MappedDeleteCollection<T, ID> paramMappedDeleteCollection, Object[] paramArrayOfObject, ObjectCache paramObjectCache)
{
  try
  {
    int i = paramDatabaseConnection.delete(paramMappedDeleteCollection.statement, paramArrayOfObject, paramMappedDeleteCollection.argFieldTypes);
    if ((i > 0) && (paramObjectCache != null))
    {
      int j = paramArrayOfObject.length;
      for (int k = 0; k < j; k++)
        paramObjectCache.remove(paramClass, paramArrayOfObject[k]);
    }
    logger.debug("delete-collection with statement '{}' and {} args, changed {} rows", paramMappedDeleteCollection.statement, Integer.valueOf(paramArrayOfObject.length), Integer.valueOf(i));
    if (paramArrayOfObject.length > 0)
      logger.trace("delete-collection arguments: {}", paramArrayOfObject);
    return i;
  }
  catch (SQLException localSQLException)
  {
    throw SqlExceptionUtil.create("Unable to run delete collection stmt: " + paramMappedDeleteCollection.statement, localSQLException);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:22,代码来源:MappedDeleteCollection.java


示例2: delete

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public int delete(DatabaseConnection paramDatabaseConnection, T paramT, ObjectCache paramObjectCache)
{
  try
  {
    Object[] arrayOfObject = getFieldObjects(paramT);
    int i = paramDatabaseConnection.delete(this.statement, arrayOfObject, this.argFieldTypes);
    logger.debug("delete data with statement '{}' and {} args, changed {} rows", this.statement, Integer.valueOf(arrayOfObject.length), Integer.valueOf(i));
    if (arrayOfObject.length > 0)
      logger.trace("delete arguments: {}", arrayOfObject);
    if ((i > 0) && (paramObjectCache != null))
    {
      Object localObject = this.idField.extractJavaFieldToSqlArgValue(paramT);
      paramObjectCache.remove(this.clazz, localObject);
    }
    return i;
  }
  catch (SQLException localSQLException)
  {
    throw SqlExceptionUtil.create("Unable to run delete stmt on object " + paramT + ": " + this.statement, localSQLException);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:22,代码来源:MappedDelete.java


示例3: deleteById

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public int deleteById(DatabaseConnection paramDatabaseConnection, ID paramID, ObjectCache paramObjectCache)
{
  try
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = convertIdToFieldObject(paramID);
    int i = paramDatabaseConnection.delete(this.statement, arrayOfObject, this.argFieldTypes);
    logger.debug("delete data with statement '{}' and {} args, changed {} rows", this.statement, Integer.valueOf(1), Integer.valueOf(i));
    logger.trace("delete arguments: {}", arrayOfObject);
    if ((i > 0) && (paramObjectCache != null))
      paramObjectCache.remove(this.clazz, paramID);
    return i;
  }
  catch (SQLException localSQLException)
  {
    throw SqlExceptionUtil.create("Unable to run deleteById stmt on id " + paramID + ": " + this.statement, localSQLException);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:MappedDelete.java


示例4: buildIterator

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> paramBaseDaoImpl, ConnectionSource paramConnectionSource, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache, int paramInt)
{
  DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
  CompiledStatement localCompiledStatement = null;
  try
  {
    localCompiledStatement = paramPreparedStmt.compile(localDatabaseConnection, StatementBuilder.StatementType.SELECT, paramInt);
    Class localClass = this.tableInfo.getDataClass();
    String str = paramPreparedStmt.getStatement();
    SelectIterator localSelectIterator = new SelectIterator(localClass, paramBaseDaoImpl, paramPreparedStmt, paramConnectionSource, localDatabaseConnection, localCompiledStatement, str, paramObjectCache);
    return localSelectIterator;
  }
  finally
  {
    if (localCompiledStatement != null)
      localCompiledStatement.close();
    if (localDatabaseConnection != null)
      paramConnectionSource.releaseConnection(localDatabaseConnection);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:StatementExecutor.java


示例5: query

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public List<T> query(ConnectionSource paramConnectionSource, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache)
{
  SelectIterator localSelectIterator = buildIterator(null, paramConnectionSource, paramPreparedStmt, paramObjectCache, -1);
  try
  {
    ArrayList localArrayList = new ArrayList();
    while (localSelectIterator.hasNextThrow())
      localArrayList.add(localSelectIterator.nextThrow());
    logger.debug("query of '{}' returned {} results", paramPreparedStmt.getStatement(), Integer.valueOf(localArrayList.size()));
    return localArrayList;
  }
  finally
  {
    localSelectIterator.close();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:17,代码来源:StatementExecutor.java


示例6: queryForFirst

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public T queryForFirst(DatabaseConnection paramDatabaseConnection, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache)
{
  CompiledStatement localCompiledStatement = paramPreparedStmt.compile(paramDatabaseConnection, StatementBuilder.StatementType.SELECT);
  try
  {
    DatabaseResults localDatabaseResults = localCompiledStatement.runQuery(paramObjectCache);
    if (localDatabaseResults.first())
    {
      logger.debug("query-for-first of '{}' returned at least 1 result", paramPreparedStmt.getStatement());
      Object localObject2 = paramPreparedStmt.mapRow(localDatabaseResults);
      return localObject2;
    }
    logger.debug("query-for-first of '{}' returned at 0 results", paramPreparedStmt.getStatement());
    return null;
  }
  finally
  {
    localCompiledStatement.close();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:StatementExecutor.java


示例7: queryRaw

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public <UO> GenericRawResults<UO> queryRaw(ConnectionSource paramConnectionSource, String paramString, RawRowMapper<UO> paramRawRowMapper, String[] paramArrayOfString, ObjectCache paramObjectCache)
{
  logger.debug("executing raw query for: {}", paramString);
  if (paramArrayOfString.length > 0)
    logger.trace("query arguments: {}", paramArrayOfString);
  DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
  CompiledStatement localCompiledStatement = null;
  try
  {
    localCompiledStatement = localDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.SELECT, noFieldTypes);
    assignStatementArguments(localCompiledStatement, paramArrayOfString);
    UserObjectRowMapper localUserObjectRowMapper = new UserObjectRowMapper(paramRawRowMapper, this);
    RawResultsImpl localRawResultsImpl = new RawResultsImpl(paramConnectionSource, localDatabaseConnection, paramString, [Ljava.lang.String.class, localCompiledStatement, localUserObjectRowMapper, paramObjectCache);
    return localRawResultsImpl;
  }
  finally
  {
    if (localCompiledStatement != null)
      localCompiledStatement.close();
    if (localDatabaseConnection != null)
      paramConnectionSource.releaseConnection(localDatabaseConnection);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:24,代码来源:StatementExecutor.java


示例8: AndroidDatabaseResults

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
public AndroidDatabaseResults(Cursor paramCursor, ObjectCache paramObjectCache)
{
  this.cursor = paramCursor;
  this.columnNames = paramCursor.getColumnNames();
  if (this.columnNames.length >= 8)
  {
    this.columnNameMap = new HashMap();
    for (int i = 0; i < this.columnNames.length; i++)
      this.columnNameMap.put(this.columnNames[i], Integer.valueOf(i));
  }
  else
  {
    this.columnNameMap = null;
  }
  this.objectCache = paramObjectCache;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:17,代码来源:AndroidDatabaseResults.java


示例9: executeRefresh

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Execute our refresh query statement and then update all of the fields in data with the fields from the result.
 * 
 * @return 1 if we found the object in the table by id or 0 if not.
 */
public int executeRefresh(DatabaseConnection databaseConnection, T data, ObjectCache objectCache)
		throws SQLException {
	@SuppressWarnings("unchecked")
	ID id = (ID) idField.extractJavaFieldValue(data);
	// we don't care about the cache here
	T result = super.execute(databaseConnection, id, null);
	if (result == null) {
		return 0;
	}
	// copy each field from the result into the passed in object
	for (FieldType fieldType : resultsFieldTypes) {
		if (fieldType != idField) {
			fieldType.assignField(data, fieldType.extractJavaFieldValue(result), false, objectCache);
		}
	}
	return 1;
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:23,代码来源:MappedRefresh.java


示例10: updateRows

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
private static <T, ID> int updateRows(DatabaseConnection databaseConnection, Class<T> clazz,
		MappedDeleteCollection<T, ID> deleteCollection, Object[] args, ObjectCache objectCache) throws SQLException {
	try {
		int rowC = databaseConnection.delete(deleteCollection.statement, args, deleteCollection.argFieldTypes);
		if (rowC > 0 && objectCache != null) {
			for (Object id : args) {
				objectCache.remove(clazz, id);
			}
		}
		logger.debug("delete-collection with statement '{}' and {} args, changed {} rows",
				deleteCollection.statement, args.length, rowC);
		if (args.length > 0) {
			// need to do the (Object) cast to force args to be a single object
			logger.trace("delete-collection arguments: {}", (Object) args);
		}
		return rowC;
	} catch (SQLException e) {
		throw SqlExceptionUtil.create("Unable to run delete collection stmt: " + deleteCollection.statement, e);
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:21,代码来源:MappedDeleteCollection.java


示例11: delete

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Delete the object from the database.
 */
public int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException {
	try {
		Object[] args = getFieldObjects(data);
		int rowC = databaseConnection.delete(statement, args, argFieldTypes);
		logger.debug("delete data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
		if (args.length > 0) {
			// need to do the (Object) cast to force args to be a single object
			logger.trace("delete arguments: {}", (Object) args);
		}
		if (rowC > 0 && objectCache != null) {
			Object id = idField.extractJavaFieldToSqlArgValue(data);
			objectCache.remove(clazz, id);
		}
		return rowC;
	} catch (SQLException e) {
		throw SqlExceptionUtil.create("Unable to run delete stmt on object " + data + ": " + statement, e);
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:22,代码来源:MappedDelete.java


示例12: deleteById

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Delete the object from the database.
 */
public int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache) throws SQLException {
	try {
		Object[] args = new Object[] { convertIdToFieldObject(id) };
		int rowC = databaseConnection.delete(statement, args, argFieldTypes);
		logger.debug("delete data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
		if (args.length > 0) {
			// need to do the (Object) cast to force args to be a single object
			logger.trace("delete arguments: {}", (Object) args);
		}
		if (rowC > 0 && objectCache != null) {
			objectCache.remove(clazz, id);
		}
		return rowC;
	} catch (SQLException e) {
		throw SqlExceptionUtil.create("Unable to run deleteById stmt on id " + id + ": " + statement, e);
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:21,代码来源:MappedDelete.java


示例13: queryForFirst

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Return the first object that matches the {@link PreparedStmt} or null if none.
 */
public T queryForFirst(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt, ObjectCache objectCache)
		throws SQLException {
	CompiledStatement compiledStatement = preparedStmt.compile(databaseConnection, StatementType.SELECT);
	DatabaseResults results = null;
	try {
		compiledStatement.setMaxRows(1);
		results = compiledStatement.runQuery(objectCache);
		if (results.first()) {
			logger.debug("query-for-first of '{}' returned at least 1 result", preparedStmt.getStatement());
			return preparedStmt.mapRow(results);
		} else {
			logger.debug("query-for-first of '{}' returned at 0 results", preparedStmt.getStatement());
			return null;
		}
	} finally {
		IOUtils.closeThrowSqlException(results, "results");
		IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:23,代码来源:StatementExecutor.java


示例14: query

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Return a list of all of the data in the table that matches the {@link PreparedStmt}. Should be used carefully if
 * the table is large. Consider using the {@link Dao#iterator} if this is the case.
 */
public List<T> query(ConnectionSource connectionSource, PreparedStmt<T> preparedStmt, ObjectCache objectCache)
		throws SQLException {
	SelectIterator<T, ID> iterator = buildIterator(/* no dao specified because no removes */null, connectionSource,
			preparedStmt, objectCache, DatabaseConnection.DEFAULT_RESULT_FLAGS);
	try {
		List<T> results = new ArrayList<T>();
		while (iterator.hasNextThrow()) {
			results.add(iterator.nextThrow());
		}
		logger.debug("query of '{}' returned {} results", preparedStmt.getStatement(), results.size());
		return results;
	} finally {
		IOUtils.closeThrowSqlException(iterator, "iterator");
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:20,代码来源:StatementExecutor.java


示例15: buildIterator

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Create and return an {@link SelectIterator} for the class using a prepared statement.
 */
public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
		PreparedStmt<T> preparedStmt, ObjectCache objectCache, int resultFlags) throws SQLException {
	DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName());
	CompiledStatement compiledStatement = null;
	try {
		compiledStatement = preparedStmt.compile(connection, StatementType.SELECT, resultFlags);
		SelectIterator<T, ID> iterator = new SelectIterator<T, ID>(tableInfo.getDataClass(), classDao, preparedStmt,
				connectionSource, connection, compiledStatement, preparedStmt.getStatement(), objectCache);
		connection = null;
		compiledStatement = null;
		return iterator;
	} finally {
		IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
		if (connection != null) {
			connectionSource.releaseConnection(connection);
		}
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:22,代码来源:StatementExecutor.java


示例16: queryRaw

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * Return a results object associated with an internal iterator that returns String[] results.
 */
public GenericRawResults<String[]> queryRaw(ConnectionSource connectionSource, String query, String[] arguments,
		ObjectCache objectCache) throws SQLException {
	logger.debug("executing raw query for: {}", query);
	if (arguments.length > 0) {
		// need to do the (Object) cast to force args to be a single object
		logger.trace("query arguments: {}", (Object) arguments);
	}
	DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName());
	CompiledStatement compiledStatement = null;
	try {
		compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes,
				DatabaseConnection.DEFAULT_RESULT_FLAGS, false);
		assignStatementArguments(compiledStatement, arguments);
		GenericRawResults<String[]> rawResults = new RawResultsImpl<String[]>(connectionSource, connection, query,
				String[].class, compiledStatement, this, objectCache);
		compiledStatement = null;
		connection = null;
		return rawResults;
	} finally {
		IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
		if (connection != null) {
			connectionSource.releaseConnection(connection);
		}
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:29,代码来源:StatementExecutor.java


示例17: SelectIterator

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
/**
 * If the statement parameter is null then this won't log information
 */
public SelectIterator(Class<?> dataClass, Dao<T, ID> classDao, GenericRowMapper<T> rowMapper,
		ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt,
		String statement, ObjectCache objectCache) throws SQLException {
	this.dataClass = dataClass;
	this.classDao = classDao;
	this.rowMapper = rowMapper;
	this.connectionSource = connectionSource;
	this.connection = connection;
	this.compiledStmt = compiledStmt;
	this.results = compiledStmt.runQuery(objectCache);
	this.statement = statement;
	if (statement != null) {
		logger.debug("starting iterator @{} for '{}'", hashCode(), statement);
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:19,代码来源:SelectIterator.java


示例18: queryForOne

import com.j256.ormlite.dao.ObjectCache; //导入依赖的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


示例19: assignIdValue

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
private void assignIdValue(T paramT, Number paramNumber, String paramString, ObjectCache paramObjectCache)
{
  this.idField.assignIdValue(paramT, paramNumber, paramObjectCache);
  if (logger.isLevelEnabled(Log.Level.DEBUG))
  {
    Logger localLogger = logger;
    Object[] arrayOfObject = new Object[4];
    arrayOfObject[0] = paramNumber;
    arrayOfObject[1] = paramString;
    arrayOfObject[2] = this.idField.getFieldName();
    arrayOfObject[3] = this.dataClassName;
    localLogger.debug("assigned id '{}' from {} to '{}' in {} object", arrayOfObject);
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:15,代码来源:MappedCreate.java


示例20: assignSequenceId

import com.j256.ormlite.dao.ObjectCache; //导入依赖的package包/类
private void assignSequenceId(DatabaseConnection paramDatabaseConnection, T paramT, ObjectCache paramObjectCache)
{
  long l = paramDatabaseConnection.queryForLong(this.queryNextSequenceStmt);
  logger.debug("queried for sequence {} using stmt: {}", Long.valueOf(l), this.queryNextSequenceStmt);
  if (l == 0L)
    throw new SQLException("Should not have returned 0 for stmt: " + this.queryNextSequenceStmt);
  assignIdValue(paramT, Long.valueOf(l), "sequence", paramObjectCache);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:9,代码来源:MappedCreate.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Location类代码示例发布时间:2022-05-22
下一篇:
Java IPrimaryEditPart类代码示例发布时间: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