Example usage for javax.persistence TypedQuery setFlushMode

List of usage examples for javax.persistence TypedQuery setFlushMode

Introduction

In this page you can find the example usage for javax.persistence TypedQuery setFlushMode.

Prototype

TypedQuery<X> setFlushMode(FlushModeType flushMode);

Source Link

Document

Set the flush mode type to be used for the query execution.

Usage

From source file:sf.net.experimaestro.scheduler.Scheduler.java

/**
 * Iterator on resources//w  w w.ja va  2 s. co m
 */
public CloseableIterable<Resource> resources() {
    final List<Resource> resultList = Transaction.evaluate(em -> {
        TypedQuery<Resource> query = em.createQuery("from resources", Resource.class);
        query.setFlushMode(FlushModeType.AUTO);
        return query.getResultList();
    });

    return new CloseableIterable<Resource>() {
        @Override
        public void close() throws CloseException {

        }

        @Override
        public Iterator<Resource> iterator() {
            return resultList.iterator();
        }
    };
}