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

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

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

Query.setBoolean介绍

[英]Bind a positional boolean-valued parameter.
[中]绑定一个位置布尔值参数。

代码示例

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

@Test
public void testBooleanHandling() {
  TestData data = new TestData();
  data.prepare();
  Session s = openSession();
  Transaction t = s.beginTransaction();
  // currently, we need the three different binds because they are different underlying types...
  int count = s.createQuery( "update BooleanLiteralEntity set yesNoBoolean = :b1, trueFalseBoolean = :b2, zeroOneBoolean = :b3" )
      .setBoolean( "b1", true )
      .setBoolean( "b2", true )
      .setBoolean( "b3", true )
      .executeUpdate();
  assertEquals( 1, count );
  BooleanLiteralEntity entity = ( BooleanLiteralEntity ) s.createQuery( "from BooleanLiteralEntity" ).uniqueResult();
  assertTrue( entity.isYesNoBoolean() );
  assertTrue( entity.isTrueFalseBoolean() );
  assertTrue( entity.isZeroOneBoolean() );
  s.clear();
  count = s.createQuery( "update BooleanLiteralEntity set yesNoBoolean = true, trueFalseBoolean = true, zeroOneBoolean = true" )
      .executeUpdate();
  assertEquals( 1, count );
  entity = ( BooleanLiteralEntity ) s.createQuery( "from BooleanLiteralEntity" ).uniqueResult();
  assertTrue( entity.isYesNoBoolean() );
  assertTrue( entity.isTrueFalseBoolean() );
  assertTrue( entity.isZeroOneBoolean() );
  t.commit();
  s.close();
  data.cleanup();
}

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

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

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

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

相关文章