org.hibernate.query.Query.setFloat()方法的使用及代码示例

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

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

Query.setFloat介绍

[英]Bind a positional float-valued parameter.
[中]绑定位置浮点值参数。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testOrdinalParameters() {
  Session s = openSession();
  Transaction t = s.beginTransaction();
  s.createQuery( "from Animal a where a.description = ?1 and a.bodyWeight = ?2" )
      .setString( 1, "something" )
      .setFloat( 2, 123f )
      .list();
  s.createQuery( "from Animal a where a.bodyWeight in (?1, ?2)" )
      .setFloat( 1, 999f )
      .setFloat( 2, 123f )
      .list();
  t.commit();
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
@SkipForDialect(
    value = CUBRIDDialect.class,
    comment = "As of version 8.4.1 CUBRID does not support temporary tables." +
        " This test somehow calls MultiTableDeleteExecutor which raises an" +
        " exception saying 'cannot doAfterTransactionCompletion multi-table" +
        " deletes using dialect not supporting temp tables'."
)
public void testParameterMixing() {
  Session s = openSession();
  Transaction t = s.beginTransaction();
  s.createQuery( "from Animal a where a.description = ?1 and a.bodyWeight = ?2 or a.bodyWeight = :bw" )
      .setString( 1, "something" )
      .setFloat( 2, 12345f )
      .setFloat( "bw", 123f )
      .list();
  t.commit();
  s.close();
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
@SuppressWarnings("deprecation")
public Query setFloat(final String name, final float val) {
  if (queryV2ForCompare != null) {
    queryV2ForCompare.setFloat(name, val);
  }
  query.setFloat(name, val);
  return this;
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
@SuppressWarnings("deprecation")
public Query setFloat(final int position, final float val) {
  if (queryV2ForCompare != null) {
    queryV2ForCompare.setFloat(position, val);
  }
  query.setFloat(adjustParameterPosition(position), val);
  return this;
}

相关文章