Class SqlBeanQuerySession<T>
- Type Parameters:
T- The row (bean) type.
- All Implemented Interfaces:
AutoCloseable
BeanQuerySession on one JDBC connection.
The connection is either passed in with SqlBeanQuerySession.Builder.connection(Connection) (the caller owns it and this session
never closes it) or taken from the context's connection source (this session gives it back on close()).
BeanQuerySession.stream(BeanQuery) and BeanQuerySession.streamValues(BeanQuery) read rows on demand; closing the stream, or the
session, closes the cursor. Every statement gets the context's fetch size and query timeout, and, for a
statement whose search includes $regex, a bounded default timeout if no explicit queryTimeout was
configured. A closed session rejects further queries with IllegalStateException.
The counts from BeanQuerySession.find(BeanQuery) and BeanQuerySession.count(BeanQuery) come from separate statements. They are a
consistent snapshot only if the caller's connection runs them in one suitably isolated transaction.
A failing statement becomes a BeanQueryExecutionException naming only the table; the SQL text (with
? placeholders) is logged at Level.WARNING with the driver's exception, whose message may include
values.
Example:
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes any open streams, then gives back the connection if this session took it from the context.protected CountsdoCount(ResolvedQuery query) Engine hook forBeanQuerySession.count(BeanQuery).doFind(ResolvedQuery query) Engine hook forBeanQuerySession.find(BeanQuery).doFindValues(ResolvedQuery query) Engine hook forBeanQuerySession.findValues(BeanQuery).doStream(ResolvedQuery query) Engine hook forBeanQuerySession.stream(BeanQuery).doStreamValues(ResolvedQuery query) Engine hook forBeanQuerySession.streamValues(BeanQuery).Returns the context that created this session (throughBeanQueryContext.createSession()or an engine'sgetSession(...)shortcut).Methods inherited from class org.apache.juneau.commons.beanquery.BeanQuerySession
columns, count, find, findValues, getMaxSearchClauses, getMaxSortKeys, page, resolve, stream, streamValues
-
Method Details
-
getContext
Returns the context that created this session (throughBeanQueryContext.createSession()or an engine'sgetSession(...)shortcut).Engines whose session builder is given a narrower context type (for example,
InMemoryBeanQuerySession) override this with a covariant return type.- Overrides:
getContextin classBeanQuerySession<T>- Returns:
- The context that created this session.
-
doFind
Description copied from class:BeanQuerySessionEngine hook forBeanQuerySession.find(BeanQuery).- Specified by:
doFindin classBeanQuerySession<T>- Parameters:
query- The validated query.- Returns:
- The page. Build it with
BeanQuerySession.page(List, ResolvedQuery, LongSupplier, LongSupplier).
-
doFindValues
Description copied from class:BeanQuerySessionEngine hook forBeanQuerySession.findValues(BeanQuery).- Specified by:
doFindValuesin classBeanQuerySession<T>- Parameters:
query- The validated query.- Returns:
- The page.
-
doCount
Description copied from class:BeanQuerySessionEngine hook forBeanQuerySession.count(BeanQuery).- Specified by:
doCountin classBeanQuerySession<T>- Parameters:
query- The validated query.- Returns:
- The counts.
-
doStream
Description copied from class:BeanQuerySessionEngine hook forBeanQuerySession.stream(BeanQuery).- Specified by:
doStreamin classBeanQuerySession<T>- Parameters:
query- The validated query.- Returns:
- The rows.
-
doStreamValues
Description copied from class:BeanQuerySessionEngine hook forBeanQuerySession.streamValues(BeanQuery).- Specified by:
doStreamValuesin classBeanQuerySession<T>- Parameters:
query- The validated query.- Returns:
- The rows.
-
close
Closes any open streams, then gives back the connection if this session took it from the context. Calling it again does nothing. After this, every query method throwsIllegalStateException.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classBeanQuerySession<T>- Throws:
BeanQueryExecutionException- If the connection cannot be released.
-