org.hibernate.Criteria.setReadOnly()方法的使用及代码示例

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

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

Criteria.setReadOnly介绍

[英]Set the read-only/modifiable mode for entities and proxies loaded by this Criteria. This setting overrides the default setting for the persistence context.
[中]为此条件加载的实体和代理设置只读/可修改模式。此设置覆盖持久性上下文的默认设置。

代码示例

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

@Test
public void testScrollCriteria() {
  Session session = openSession();
  Transaction t = session.beginTransaction();
  Course course = new Course();
  course.setCourseCode("HIB");
  course.setDescription("Hibernate Training");
  session.persist(course);
  session.flush();
  session.clear();
  ScrollableResults sr = session.createCriteria(Course.class).setReadOnly( true ).scroll();
  assertTrue( sr.next() );
  course = (Course) sr.get(0);
  assertNotNull(course);
  assertTrue( session.isReadOnly( course ) );
  sr.close();
  session.delete(course);
  t.commit();
  session.close();
}

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

.setReadOnly( true )
.list();

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

.add( Restrictions.isNotEmpty("s.enrolments") )
.setCacheable(true)
.setReadOnly( true )
.list();
.createAlias("student", "s")
.createAlias("course", "c")
.setReadOnly( true )
.add( Restrictions.isNotEmpty("s.enrolments") )
.setCacheable(true)
.setReadOnly( true )
.list();
.setReadOnly( true )
.createAlias("student", "s")
.createAlias("course", "c")

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

coursePreferred = ( Course ) s.get( Course.class, coursePreferred.getCourseCode() );
assertFalse( s.isReadOnly( coursePreferred ) );
Criteria criteria = s.createCriteria( Student.class ).setReadOnly( true );
assertTrue( criteria.isReadOnlyInitialized() );
assertTrue( criteria.isReadOnly() );

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

assertFalse( s.isReadOnly( coursePreferred ) );
s.setReadOnly( coursePreferred, true );
Criteria criteria = s.createCriteria( Student.class ).setReadOnly( false );
assertTrue( criteria.isReadOnlyInitialized() );
assertFalse( criteria.isReadOnly() );

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

Hibernate.initialize( coursePreferred );
checkProxyReadOnly( s, coursePreferred, false );
Criteria criteria = s.createCriteria( Student.class ).setReadOnly( true );
assertTrue( criteria.isReadOnlyInitialized() );
assertTrue( criteria.isReadOnly() );

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

s.setReadOnly( coursePreferred, true );
checkProxyReadOnly( s, coursePreferred, true );
Criteria criteria = s.createCriteria( Student.class ).setReadOnly( false );
assertTrue( criteria.isReadOnlyInitialized() );
assertFalse( criteria.isReadOnly() );

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

assertFalse( Hibernate.isInitialized( coursePreferred ) );
checkProxyReadOnly( s, coursePreferred, false );
Criteria criteria = s.createCriteria( Student.class ).setReadOnly( true );
assertTrue( criteria.isReadOnlyInitialized() );
assertTrue( criteria.isReadOnly() );

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

s.setReadOnly( coursePreferred, true );
checkProxyReadOnly( s, coursePreferred, true );
Criteria criteria = s.createCriteria( Student.class ).setReadOnly( false );
assertTrue( criteria.isReadOnlyInitialized() );
assertFalse( criteria.isReadOnly() );

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

Criteria criteria = s.createCriteria( Student.class ).setReadOnly( true );
assertFalse( s.isDefaultReadOnly() );
assertTrue( criteria.isReadOnlyInitialized() );

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

assertFalse( criteria.isReadOnlyInitialized() );
assertFalse( criteria.isReadOnly() );
criteria.setReadOnly( false );
assertTrue( criteria.isReadOnlyInitialized() );
assertFalse( criteria.isReadOnly() );

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

assertFalse( criteria.isReadOnlyInitialized() );
assertTrue( criteria.isReadOnly() );
criteria.setReadOnly( false );
assertTrue( criteria.isReadOnlyInitialized() );
assertFalse( criteria.isReadOnly() );

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

assertFalse( criteria.isReadOnlyInitialized() );
assertTrue( criteria.isReadOnly() );
criteria.setReadOnly( true );
assertTrue( criteria.isReadOnlyInitialized() );
assertTrue( criteria.isReadOnly() );

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

gavin = ( Student ) s.createCriteria(Student.class)
  .add( Subqueries.exists(dc) )
  .setReadOnly( true )
  .uniqueResult();
assertFalse( s.isDefaultReadOnly() );
enrolment = ( Enrolment ) s.createCriteria(Enrolment.class, "e")
  .add( Subqueries.eq("Gavin King", dc2) )
  .setReadOnly( true )
  .uniqueResult();
assertTrue( s.isReadOnly( enrolment ) );
enrolment = ( Enrolment ) s.createCriteria(Enrolment.class, "e")
  .add( Subqueries.eq("Gavin King", dc3) )
  .setReadOnly( true )
  .uniqueResult();
assertTrue( s.isReadOnly( enrolment ) );

代码示例来源:origin: org.grails/grails-datastore-gorm-hibernate-core

/**
 * Whether to check for changes on the objects loaded
 * @param readOnly True to disable dirty checking
 */
public BuildableCriteria readOnly(boolean readOnly) {
  criteria.setReadOnly(readOnly);
  return this;
}

代码示例来源:origin: TGAC/miso-lims

@Override
public Criteria setReadOnly(boolean readOnly) {
 backingCriteria.setReadOnly(readOnly);
 return this;
}

代码示例来源:origin: com.github.vsspt/db-generic-dao-spring-hibernate

private void setReadOnly(final Criteria criteria) {
 criteria.setReadOnly(Boolean.TRUE);
}

代码示例来源:origin: at.chrl/chrl-orm

/**
 * Creates {@link Stream} with given criteria Result
 * 
 * @param crit
 *            - given Critera crit. crit is marked as ReadOnly with
 *            {@link Query#setReadOnly(true)}
 * @return new {@link Stream} with given ResultSet
 */
public <T> Stream<T> streamReadOnly(Criteria crit) {
  return stream(crit.setReadOnly(true));
}

代码示例来源:origin: stackoverflow.com

Criteria criteria = getCurrentSession().createCriteria(LargeVolumeEntity.class);
criteria.add(Restrictions.eq("archived", Boolean.FALSE));
criteria.setReadOnly(true);
criteria.setCacheable(false);
List<E> result = new IterableListScrollableResults<E>(getCurrentSession(),
    criteria.scroll(ScrollMode.FORWARD_ONLY));
for(E entity : result) {
  dumpEntity(file, entity);
}

代码示例来源:origin: stackoverflow.com

Criteria criteria = getCurrentSession().createCriteria(LargeVolumeEntity.class);
criteria.add(Restrictions.eq("archived", Boolean.FALSE));
criteria.setReadOnly(true);
criteria.setCacheable(false);
List<E> result = new IterableListScrollableResults<E>(getCurrentSession(),
    criteria.scroll(ScrollMode.FORWARD_ONLY));
for(E entity : result) {
  dumpEntity(file, entity);
}

相关文章