本文整理了Java中org.hibernate.query.Query.setBoolean
方法的一些代码示例,展示了Query.setBoolean
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setBoolean
方法的具体详情如下:
包路径:org.hibernate.query.Query
类名称: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;
}
内容来源于网络,如有侵权,请联系作者删除!