Example usage for javax.persistence FlushModeType AUTO

List of usage examples for javax.persistence FlushModeType AUTO

Introduction

In this page you can find the example usage for javax.persistence FlushModeType AUTO.

Prototype

FlushModeType AUTO

To view the source code for javax.persistence FlushModeType AUTO.

Click Source Link

Document

(Default) Flushing to occur at query execution.

Usage

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

/**
 * Iterator on resources/*from   w  w w .  j  ava2  s  .com*/
 */
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();
        }
    };
}