com.j256.ormlite.dao.Dao.getRawRowMapper()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(174)

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

Dao.getRawRowMapper介绍

[英]Return a row mapper that is suitable for use with #queryRaw(String,RawRowMapper,String...). This is a bit experimental at this time. It most likely will not work with all databases since the string output for each data type is hard to forecast. Please provide feedback.
[中]返回适合与#queryRaw一起使用的行映射器(String,RawRowMapper,String…)。这是一个有点实验在这个时候。它很可能不会适用于所有数据库,因为很难预测每种数据类型的字符串输出。请提供反馈。

代码示例

代码示例来源:origin: magefree/mage

public List<CardInfo> findCardsCaseInsensitive(String name) {
  try {
    String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("\'", "\'\'");
    GenericRawResults<CardInfo> rawResults = cardDao.queryRaw(
        "select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'',
        cardDao.getRawRowMapper());
    List<CardInfo> result = new ArrayList<>();
    for (CardInfo cardinfo : rawResults) {
      result.add(cardinfo);
    }
    return result;
  } catch (SQLException ex) {
    Logger.getLogger(CardRepository.class).error("Error during execution of raw sql statement", ex);
  }
  return Collections.emptyList();
}

代码示例来源:origin: magefree/mage

public ExpansionInfo[] getWithBoostersSortedByReleaseDate() {
  try {
    // only with boosters and cards
    GenericRawResults<ExpansionInfo> setsList = expansionDao.queryRaw(
        "select * from expansion e "
            + " where e.boosters = 1 "
            + "   and exists(select (1) from  card c where c.setcode = e.code) "
            + " order by e.releasedate desc",
        expansionDao.getRawRowMapper());
    List<ExpansionInfo> resList = new ArrayList<>();
    for (ExpansionInfo info : setsList) {
      resList.add(info);
    }
    return resList.toArray(new ExpansionInfo[0]);
  } catch (SQLException ex) {
    logger.error(ex);
    return new ExpansionInfo[0];
  }
}

代码示例来源:origin: j256/ormlite-core

/**
 * @see Dao#getRawRowMapper()
 */
@Override
public RawRowMapper<T> getRawRowMapper() {
  return dao.getRawRowMapper();
}

代码示例来源:origin: com.j256.ormlite/ormlite-core

/**
 * @see Dao#getRawRowMapper()
 */
@Override
public RawRowMapper<T> getRawRowMapper() {
  return dao.getRawRowMapper();
}

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

GenericRawResults<MetricsCounterTypeDevice> rawResult = DaoUtils
    .getMetricsCounterTypeDeviceDao().getDao().queryRaw(sqlSelectQuery,
        DaoUtils.getMetricsCounterTypeDeviceDao().getDao().getRawRowMapper());
metric = rawResult.getFirstResult();
_logger.debug("Metric:[{}]", metric);

代码示例来源:origin: mycontroller-org/mycontroller

GenericRawResults<MetricsCounterTypeDevice> rawResult = DaoUtils
    .getMetricsCounterTypeDeviceDao().getDao().queryRaw(sqlSelectQuery,
        DaoUtils.getMetricsCounterTypeDeviceDao().getDao().getRawRowMapper());
metric = rawResult.getFirstResult();
_logger.debug("Metric:[{}]", metric);

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

GenericRawResults<MetricsDoubleTypeDevice> rawResult = DaoUtils
    .getMetricsDoubleTypeDeviceDao().getDao().queryRaw(sqlSelectQuery,
        DaoUtils.getMetricsDoubleTypeDeviceDao().getDao().getRawRowMapper());
metric = rawResult.getFirstResult();
_logger.debug("Metric:[{}]", metric);

代码示例来源:origin: mycontroller-org/mycontroller

GenericRawResults<MetricsBatteryUsage> rawResult = DaoUtils
    .getMetricsBatteryUsageDao().getDao().queryRaw(sqlSelectQuery,
        DaoUtils.getMetricsBatteryUsageDao().getDao().getRawRowMapper());
metric = rawResult.getFirstResult();
_logger.debug("Metric:[{}]", metric);

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

GenericRawResults<MetricsBatteryUsage> rawResult = DaoUtils
    .getMetricsBatteryUsageDao().getDao().queryRaw(sqlSelectQuery,
        DaoUtils.getMetricsBatteryUsageDao().getDao().getRawRowMapper());
metric = rawResult.getFirstResult();
_logger.debug("Metric:[{}]", metric);

代码示例来源:origin: mycontroller-org/mycontroller

GenericRawResults<MetricsDoubleTypeDevice> rawResult = DaoUtils
    .getMetricsDoubleTypeDeviceDao().getDao().queryRaw(sqlSelectQuery,
        DaoUtils.getMetricsDoubleTypeDeviceDao().getDao().getRawRowMapper());
metric = rawResult.getFirstResult();
_logger.debug("Metric:[{}]", metric);

代码示例来源:origin: j256/ormlite-core

@Test
public void testQueryRawUsingRawRowMapper() throws Exception {
  Dao<Foo, Integer> dao = createDao(Foo.class, true);
  Foo foo1 = new Foo();
  int equal1 = 1231231232;
  foo1.equal = equal1;
  assertEquals(1, dao.create(foo1));
  Foo foo2 = new Foo();
  int equal2 = 1231232;
  foo2.equal = equal2;
  assertEquals(1, dao.create(foo2));
  QueryBuilder<Foo, Integer> queryBuilder = dao.queryBuilder();
  queryBuilder.where().eq(Foo.ID_COLUMN_NAME, foo1.id);
  GenericRawResults<Foo> results =
      dao.queryRaw("SELECT " + Foo.ID_COLUMN_NAME + " FROM FOO", dao.getRawRowMapper());
  List<Foo> resultList = results.getResults();
  assertEquals(2, resultList.size());
  assertEquals(foo1.id, resultList.get(0).id);
  assertEquals(0, resultList.get(0).equal);
  assertEquals(foo2.id, resultList.get(1).id);
  assertEquals(0, resultList.get(0).equal);
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testCountInReadOnlyField() throws Exception {
  Dao<AsField, Integer> dao = createDao(AsField.class, true);
  AsField foo1 = new AsField();
  int val1 = 123213;
  foo1.val = val1;
  assertEquals(1, dao.create(foo1));
  AsField foo2 = new AsField();
  int val2 = 122433213;
  foo2.val = val2;
  assertEquals(1, dao.create(foo2));
  QueryBuilder<AsField, Integer> qb = dao.queryBuilder();
  qb.selectRaw("*");
  int val3 = 12;
  qb.selectRaw(val3 + " AS " + AsField.SUM_FIELD);
  List<AsField> results = dao.queryRaw(qb.prepareStatementString(), dao.getRawRowMapper()).getResults();
  assertEquals(2, results.size());
  assertEquals(val1, (int) results.get(0).val);
  assertEquals(val3, (int) results.get(0).sum);
  assertEquals(val2, (int) results.get(1).val);
  assertEquals(val3, (int) results.get(1).sum);
}

代码示例来源:origin: j256/ormlite-core

qb.selectRaw("string, max(val) as val");
qb.groupBy(Foo.STRING_COLUMN_NAME);
GenericRawResults<Foo> results = dao.queryRaw(qb.prepareStatementString(), dao.getRawRowMapper());
assertNotNull(results);
CloseableIterator<Foo> iterator = results.closeableIterator();

代码示例来源:origin: j256/ormlite-core

qb.selectRaw("MAX(val) AS val");
qb.groupBy(Foo.STRING_COLUMN_NAME);
GenericRawResults<Foo> results = dao.queryRaw(qb.prepareStatementString(), dao.getRawRowMapper());
assertNotNull(results);
CloseableIterator<Foo> iterator = results.closeableIterator();

相关文章