BrightSide Workbench Full Report + Source Code
org.turro.jpa.stream.DaoStream< T > Class Template Reference

Public Member Functions

 DaoStream (Dao dao, String query)
 
 DaoStream (Dao dao, WhereClause wc)
 
 DaoStream (Dao dao, SqlClause sc)
 
 DaoStream (Dao dao, AbstractJpaQuery< T > query)
 
Stream< T > stream ()
 
Stream< T > stream (int batchSize)
 

Static Public Member Functions

static AtomicCounter getCounter ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 34 of file DaoStream.java.

Constructor & Destructor Documentation

◆ DaoStream() [1/4]

org.turro.jpa.stream.DaoStream< T >.DaoStream ( Dao  dao,
String  query 
)

Definition at line 43 of file DaoStream.java.

43  {
44  this(dao, new WhereClause());
45  wc.addClause(query);
46  }
Here is the call graph for this function:

◆ DaoStream() [2/4]

Definition at line 48 of file DaoStream.java.

48  {
49  this.dao = dao;
50  this.wc = wc;
51  this.sc = null;
52  this.query = null;
53  }

◆ DaoStream() [3/4]

org.turro.jpa.stream.DaoStream< T >.DaoStream ( Dao  dao,
SqlClause  sc 
)

Definition at line 55 of file DaoStream.java.

55  {
56  this.dao = dao;
57  this.wc = null;
58  this.sc = sc;
59  this.query = null;
60  }

◆ DaoStream() [4/4]

Definition at line 62 of file DaoStream.java.

62  {
63  this.dao = dao;
64  this.wc = null;
65  this.sc = null;
66  this.query = query;
67  }

Member Function Documentation

◆ getCounter()

static AtomicCounter org.turro.jpa.stream.DaoStream< T >.getCounter ( )
static

Definition at line 136 of file DaoStream.java.

136  {
137  return openStreams;
138  }

◆ stream() [1/2]

Stream<T> org.turro.jpa.stream.DaoStream< T >.stream ( )

Definition at line 75 of file DaoStream.java.

75  {
76  return stream(100);
77  }
Here is the caller graph for this function:

◆ stream() [2/2]

Stream<T> org.turro.jpa.stream.DaoStream< T >.stream ( int  batchSize)

Definition at line 79 of file DaoStream.java.

79  {
80  manager = new DaoManager(dao);
81  Query q = null;
82  if(query != null) {
83  q = (Query) manager.createQuery(query.query());
84  } else if(wc != null) {
85  q = (Query) manager.createQuery(wc.getClause());
86  wc.setNamedParameters(q);
87  } else if(sc != null) {
88  q = (Query) manager.createQuery(sc.clause());
89  manager.setNamedParameters(q, sc.getNamedValues());
90  }
91  if(q != null) {
92  //q.setReadOnly(true);
93  //q.setLockMode(LockModeType.NONE);
94  //q.setFetchSize(batchSize);
95  openStreams.increment();
96  return (Stream<T>) q.<T>stream().onClose(() -> {
97  manager.close();
98  openStreams.decrement();
99  });
100  }
101  return null;
102 // results = q.scroll(ScrollMode.FORWARD_ONLY);
103 // return Stream
104 // .generate(() -> next(batchSize))
105 // .takeWhile(Predicate.not(List::isEmpty))
106 // .flatMap(List::stream)
107 // .onClose(() -> {
108 // results.close();
109 // manager.close();
110 // openStreams.decrement();
111 // });
112  }
void setNamedParameters(Query q, Map< String, Object > parameters)
Here is the call graph for this function:

The documentation for this class was generated from the following file: