本文整理了Java中org.hibernate.Query.setFlushMode
方法的一些代码示例,展示了Query.setFlushMode
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setFlushMode
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setFlushMode
[英]Override the current session flush mode, just for this query.
[中]覆盖当前会话刷新模式,仅用于此查询。
代码示例来源:origin: hibernate/hibernate-orm
/**
* (Re)set the current FlushMode in effect for this query.
*
* @param flushMode The new FlushMode to use.
*
* @return {@code this}, for method chaining
*
* @see #getHibernateFlushMode()
*/
@SuppressWarnings("unchecked")
default Query<R> setHibernateFlushMode(FlushMode flushMode) {
setFlushMode( flushMode );
return this;
}
代码示例来源:origin: openmrs/openmrs-core
@Override
public List<Object[]> getOrderFromDatabase(Order order, boolean isOrderADrugOrder) throws APIException {
String sql = "SELECT patient_id, care_setting, concept_id FROM orders WHERE order_id = :orderId";
if (isOrderADrugOrder) {
sql = " SELECT o.patient_id, o.care_setting, o.concept_id, d.drug_inventory_id "
+ " FROM orders o, drug_order d WHERE o.order_id = d.order_id AND o.order_id = :orderId";
}
Query query = sessionFactory.getCurrentSession().createSQLQuery(sql);
query.setParameter("orderId", order.getOrderId());
//prevent hibernate from flushing before fetching the list
query.setFlushMode(FlushMode.MANUAL);
return query.list();
}
代码示例来源:origin: ezbz/projectx
@Override
public Query setFlushMode(final FlushMode flushMode) {
return query.setFlushMode(flushMode);
}
代码示例来源:origin: hibernate/hibernate-entitymanager
public Query setFlushMode(FlushModeType flushMode) {
if ( flushMode == FlushModeType.AUTO ) {
query.setFlushMode( FlushMode.AUTO );
}
else if ( flushMode == FlushModeType.COMMIT ) {
query.setFlushMode( FlushMode.COMMIT );
}
return this;
}
}
代码示例来源:origin: riotfamily/riot
public TypedQuery<T> setFlushMode(FlushMode flushMode) {
query.setFlushMode(flushMode);
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
@Override
protected void applyFlushMode(FlushMode flushMode) {
query.setFlushMode( flushMode );
}
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public Query setFlushMode(FlushMode flushMode) {
return query.setFlushMode(flushMode);
}
代码示例来源:origin: hibernate/hibernate
private List getList() {
if (list==null) {
if ( log.isDebugEnabled() ) {
log.debug("loading query-list using named query: " + queryName);
}
list = session.getNamedQuery(queryName)
.setProperties(owner)
.setFlushMode(FlushMode.NEVER) //TODO: should this really override the setting in the query definition?
.list();
}
return list;
}
代码示例来源:origin: org.bedework/bw-util-hibernate
@Override
public void createNoFlushQuery(final String s) throws HibException {
if (exc != null) {
// Didn't hear me last time?
throw new HibException(exc);
}
try {
q = sess.createQuery(s);
crit = null;
q.setFlushMode(FlushMode.COMMIT);
} catch (Throwable t) {
handleException(t);
}
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-v51
@Override
public List execQueryListAutoFlush(Object session, String query, String[]... params) {
Query q = ((Session) session).createQuery(query).setFlushMode(FlushMode.AUTO);
setParams(q, params);
return q.list();
}
代码示例来源:origin: at.chrl/chrl-orm
/**
* crates a Stream with given {@link Query} q
*
* @param q
* - given Query
* @return new {@link Stream} with given ResultSet
*/
public <T> Stream<T> stream(Query q) {
if(TransactionStatus.NOT_ACTIVE.equals(session.getTransaction().getStatus()))
session.beginTransaction();
if (loggingEnabled)
logQuery(false);
return StreamSupport.<T> stream(Spliterators.spliteratorUnknownSize(
new QueryIterator<T>(q.setCacheMode(CacheMode.IGNORE)
.setFlushMode(FlushMode.MANUAL), this, false),
Spliterator.ORDERED | Spliterator.DISTINCT), false);
}
代码示例来源:origin: org.sakaiproject.sitestats/sitestats-impl
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.createQuery(hql);
q.setFlushMode(FlushMode.NEVER);
q.setString("siteid", siteId);
if(events != null && events.size() > 0)
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-v51
@Override
public int execQueryUpdateAutoFlush(Object session, String query, String[]... params) {
Query q = ((Session) session).createQuery(query).setFlushMode(FlushMode.AUTO);
setParams(q, params);
return q.executeUpdate();
}
代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate
query.setFlushMode(flushMode);
代码示例来源:origin: hibernate/hibernate-entitymanager
query.setFlushMode( ConfigurationHelper.getFlushMode( value ) );
代码示例来源:origin: hibernate/hibernate
public void initialize(Serializable key, SessionImplementor session)
throws HibernateException {
if ( log.isDebugEnabled() ) {
log.debug("initializing collection: " + persister.getRole() + " using named query: " + queryName );
}
//TODO: is there a more elegant way than downcasting?
AbstractQueryImpl query = (AbstractQueryImpl) session.getNamedQuery(queryName);
if ( query.getNamedParameters().length>0 ) {
query.setParameter(
query.getNamedParameters()[0],
key,
persister.getKeyType()
);
}
else {
query.setParameter( 0, key, persister.getKeyType() );
}
query.setCollectionKey(key)
.setFlushMode(FlushMode.NEVER)
.list();
}
}
代码示例来源:origin: hibernate/hibernate
query.setParameter( 0, id, persister.getIdentifierType() );
query.setFlushMode(FlushMode.NEVER).list();
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
public void initialize(Serializable key, SessionImplementor session)
throws HibernateException {
if ( log.isDebugEnabled() ) {
log.debug(
"initializing collection: " +
persister.getRole() +
" using named query: " +
queryName
);
}
//TODO: is there a more elegant way than downcasting?
AbstractQueryImpl query = (AbstractQueryImpl) session.getNamedSQLQuery(queryName);
if ( query.getNamedParameters().length>0 ) {
query.setParameter(
query.getNamedParameters()[0],
key,
persister.getKeyType()
);
}
else {
query.setParameter( 0, key, persister.getKeyType() );
}
query.setCollectionKey( key )
.setFlushMode( FlushMode.MANUAL )
.list();
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public void initialize(Serializable key, SessionImplementor session)
throws HibernateException {
LOG.debugf("Initializing collection: %s using named query: %s", persister.getRole(), queryName);
//TODO: is there a more elegant way than downcasting?
AbstractQueryImpl query = (AbstractQueryImpl) session.getNamedSQLQuery(queryName);
if ( query.getNamedParameters().length>0 ) {
query.setParameter(
query.getNamedParameters()[0],
key,
persister.getKeyType()
);
}
else {
query.setParameter( 0, key, persister.getKeyType() );
}
query.setCollectionKey( key )
.setFlushMode( FlushMode.MANUAL )
.list();
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public void initialize(Serializable key, SessionImplementor session)
throws HibernateException {
LOG.debugf("Initializing collection: %s using named query: %s", persister.getRole(), queryName);
//TODO: is there a more elegant way than downcasting?
AbstractQueryImpl query = (AbstractQueryImpl) session.getNamedSQLQuery(queryName);
if ( query.getNamedParameters().length>0 ) {
query.setParameter(
query.getNamedParameters()[0],
key,
persister.getKeyType()
);
}
else {
query.setParameter( 0, key, persister.getKeyType() );
}
query.setCollectionKey( key )
.setFlushMode( FlushMode.MANUAL )
.list();
}
}
内容来源于网络,如有侵权,请联系作者删除!