R
- type of source row classpublic class DurableLazySelector<R> extends AbstractLazySelector<R>
DataSource
or data source name to create the
Database
when performing the lazy select. Source rows must be selected with an operation that uses
a database created with Database.Database(DataSource)
,
Database.Database(DataSource, String)
, Database.Database(String)
, or Database.Database(String, String)
This class is slightly less efficient than SimpleLazySelector
because a Database
and Table
are created
when selector needs to be used. It is more flexible since it can be used any time even when original connection has been closed.
DurableLazySelector is good for scenario's when source row may be serialized to disk, for example, in web application where source row is stored in web session.
Constructor and Description |
---|
DurableLazySelector()
Constructs for use when DurableLazySelector is base class of row that will contain lazy select fields.
|
DurableLazySelector(R source)
Constructs for use as delegate for row that will contain lazy select fields.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeDatabase()
Closes
Database created with openDatabase() . |
javax.sql.DataSource |
getDataSource()
Gets the
DataSource from database used by pendingLazySelects(Database) . |
java.lang.String |
getDataSourceName()
Gets the JNDI name to use to look up
DataSource . |
java.lang.String |
getSchema()
Gets the schema from database used by
pendingLazySelects(Database) . |
protected void |
openDatabase()
Creates a new instance of a
Database from data source name or data source obtained in
pendingLazySelects(Database) . |
void |
pendingLazySelects(Database database)
DataSource and schema are obtained from database parameter. |
begin, checkLazySelects, commit, getDatabase, getPendingLazySelectFields, getSource, initPendingLazySelectCascadeFields, isLocalTransaction, isPendingLazySelects, isUseTransaction, lazySelect, rollback, setDatabase, setUseTransaction
public DurableLazySelector()
AbstractLazySelector.setUseTransaction(boolean)
is true by default.public DurableLazySelector(R source)
AbstractLazySelector.setUseTransaction(boolean)
is true by default.source
- row that contains fields with SelectCascade.lazy()
is true; typically source
is the one side of a one-to-many relationship or source has a reference to the other class in a
one-to-one relationshippublic void pendingLazySelects(Database database) throws LazyCascadeException
DataSource
and schema are obtained from database parameter.pendingLazySelects
in interface LazySelectable
pendingLazySelects
in class AbstractLazySelector<R>
database
- database that was used to select source rowLazyCascadeException
- if Database.getDataSource()
is nullpublic java.lang.String getDataSourceName()
DataSource
. This name was obtained from database by
pendingLazySelects(Database)
.public javax.sql.DataSource getDataSource()
DataSource
from database used by pendingLazySelects(Database)
.public java.lang.String getSchema()
pendingLazySelects(Database)
.protected void openDatabase() throws LazyCascadeException
Database
from data source name or data source obtained in
pendingLazySelects(Database)
. Data source will be looked up in JNDI if data source
name is known and data source is not known.openDatabase
in class AbstractLazySelector<R>
LazyCascadeException
- if errorprotected void closeDatabase() throws LazyCascadeException
Database
created with openDatabase()
.closeDatabase
in class AbstractLazySelector<R>
LazyCascadeException
- if error