本文整理了Java中org.hibernate.Query.setReadOnly
方法的一些代码示例,展示了Query.setReadOnly
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setReadOnly
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setReadOnly
[英]Set the read-only/modifiable mode for entities and proxies loaded by this Query. This setting overrides the default setting for the persistence context.
[中]为此查询加载的实体和代理设置只读/可修改模式。此设置覆盖持久性上下文的默认设置。
代码示例来源:origin: hibernate/hibernate-orm
List list = s.createFilter( c.getLazyDataPoints(), "" )
.setMaxResults(1)
.setReadOnly( true )
.list();
assertEquals( 1, list.size() );
list = s.createFilter( c.getNonLazyJoinDataPoints(), "" )
.setMaxResults(1)
.setReadOnly( true )
.list();
assertEquals( 1, list.size() );
list = s.createFilter( c.getNonLazySelectDataPoints(), "" )
.setMaxResults(1)
.setReadOnly( true )
.list();
assertEquals( 1, list.size() );
代码示例来源:origin: hibernate/hibernate-orm
List list = s.createFilter( c.getLazyDataPoints(), "" )
.setMaxResults(1)
.setReadOnly( false )
.list();
assertEquals( 1, list.size() );
list = s.createFilter( c.getNonLazyJoinDataPoints(), "" )
.setMaxResults(1)
.setReadOnly( false )
.list();
assertEquals( 1, list.size() );
list = s.createFilter( c.getNonLazySelectDataPoints(), "" )
.setMaxResults(1)
.setReadOnly( false )
.list();
assertEquals( 1, list.size() );
代码示例来源:origin: hibernate/hibernate-orm
s.setDefaultReadOnly( false );
assertFalse( query.isReadOnly() );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
s.setDefaultReadOnly( true );
s.setDefaultReadOnly( false );
assertTrue( query.isReadOnly() );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
s.setDefaultReadOnly( true );
assertFalse( query.isReadOnly() );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
s.setDefaultReadOnly( false );
DataPoint dpLast = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
assertFalse( s.isReadOnly( dpLast ) );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
int nExpectedChanges = 0;
代码示例来源:origin: hibernate/hibernate-orm
s.setDefaultReadOnly( true );
assertTrue( query.isReadOnly() );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
s.setDefaultReadOnly( false );
s.setDefaultReadOnly( true );
assertFalse( query.isReadOnly() );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
s.setDefaultReadOnly( false );
assertTrue( query.isReadOnly() );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
s.setDefaultReadOnly( true );
DataPoint dpLast = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
assertTrue( s.isReadOnly( dpLast ) );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
int nExpectedChanges = 0;
代码示例来源:origin: hibernate/hibernate-orm
s.setDefaultReadOnly( true );
assertTrue( query.isReadOnly() );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
s.setDefaultReadOnly( false );
s.setDefaultReadOnly( true );
assertFalse( query.isReadOnly() );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
s.setDefaultReadOnly( false );
assertTrue( query.isReadOnly() );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
s.setDefaultReadOnly( true );
DataPoint dpLast = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
assertTrue( s.isReadOnly( dpLast ) );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
int nExpectedChanges = 0;
代码示例来源:origin: hibernate/hibernate-orm
s.setDefaultReadOnly( false );
assertFalse( query.isReadOnly() );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
s.setDefaultReadOnly( true );
s.setDefaultReadOnly( false );
assertTrue( query.isReadOnly() );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
s.setDefaultReadOnly( true );
assertFalse( query.isReadOnly() );
query.setReadOnly( true );
assertTrue( query.isReadOnly() );
s.setDefaultReadOnly( false );
DataPoint dpLast = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
assertFalse( s.isReadOnly( dpLast ) );
query.setReadOnly( false );
assertFalse( query.isReadOnly() );
int nExpectedChanges = 0;
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: ezbz/projectx
@Override
public Query setReadOnly(final boolean readOnly) {
return query.setReadOnly(readOnly);
}
代码示例来源:origin: org.sakaiproject.samigo/samigo-services
private int countItems(Map<String, String> hqlQueries, Session session) {
@SuppressWarnings("unchecked")
final List<Integer> totalItemsResult = session
.createQuery(hqlQueries.get(TOTAL_ITEM_COUNT_HQL))
.setReadOnly(true).list();
return totalItemsResult.get(0);
}
代码示例来源:origin: sakaiproject/sakai
private int countItems(Map<String, String> hqlQueries, Session session) {
@SuppressWarnings("unchecked")
final List<Integer> totalItemsResult = session
.createQuery(hqlQueries.get(TOTAL_ITEM_COUNT_HQL))
.setReadOnly(true).list();
return totalItemsResult.get(0);
}
代码示例来源:origin: sakaiproject/sakai
private int countItemsNeedingHashBackfill(Map<String, String> hqlQueries, Session session) {
@SuppressWarnings("unchecked")
final List<Integer> totalItemsNeedingBackfillResult = session
.createQuery(hqlQueries.get(TOTAL_HASH_BACKFILLABLE_ITEM_COUNT_HQL))
.setReadOnly(true).list();
return totalItemsNeedingBackfillResult.get(0);
}
代码示例来源:origin: org.sakaiproject.samigo/samigo-services
private int countItemsNeedingHashBackfill(Map<String, String> hqlQueries, Session session) {
@SuppressWarnings("unchecked")
final List<Integer> totalItemsNeedingBackfillResult = session
.createQuery(hqlQueries.get(TOTAL_HASH_BACKFILLABLE_ITEM_COUNT_HQL))
.setReadOnly(true).list();
return totalItemsNeedingBackfillResult.get(0);
}
代码示例来源:origin: at.chrl/chrl-orm
/**
* Creates {@link Stream} with given query Result
*
* @param q
* - given Query q. q is marked as ReadOnly with
* {@link Query#setReadOnly(true)}
* @return new {@link Stream} with given ResultSet
*/
public <T> Stream<T> streamReadOnly(Query q) {
return stream(q.setReadOnly(true));
}
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
public int getCasesNumber(final String ownerName, final String labelName) {
final Query query = getSession().getNamedQuery("getCasesNumber");
query.setString("ownerName", ownerName);
query.setString("label", labelName);
query.setReadOnly(true);
return ((Long) query.uniqueResult()).intValue();
}
代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate
public boolean checkRoute(CorrelationKeySet correlationKeySet) {
entering("CorrelatorDaoImpl.checkRoute");
Query q = getSession().getNamedQuery(HCorrelatorSelector.SELECT_MESSAGE_ROUTE);
q.setEntity("corr",_hobj);
q.setString("ckey", correlationKeySet.toCanonicalString());
q.setReadOnly(true);
return q.list().isEmpty();
}
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
setFetchSize(Integer.MIN_VALUE); //MUST use Integer.MIN_VALUE, other value=fetch all
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
}
results.close();
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
public int getCasesNumberWithTwoLabels(final String ownerName, final String label1Name, final String label2Name) {
final Query query = getSession().getNamedQuery("getCasesNumberWithTwoLabels");
query.setString("label1", CaseImpl.buildLabel(ownerName, label1Name));
query.setString("label2", CaseImpl.buildLabel(ownerName, label2Name));
query.setReadOnly(true);
return ((Long) query.uniqueResult()).intValue();
}
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to flush() as well
}
results.close();
内容来源于网络,如有侵权,请联系作者删除!