org.sormula.operation.cascade.lazy
Class SimpleLazySelector<R>

java.lang.Object
  extended by org.sormula.operation.cascade.lazy.AbstractLazySelector<R>
      extended by org.sormula.operation.cascade.lazy.SimpleLazySelector<R>
Type Parameters:
R - type of source row class
All Implemented Interfaces:
java.io.Serializable, LazySelectable

public class SimpleLazySelector<R>
extends AbstractLazySelector<R>

A lazy cascade selector that uses the same Database that was used to select source row.

SimpleLazySelector is good for scenario's when source row is maintained in memory and database/connection used to select the source row remains open. Scenario's like this occur in stand-alone applications and web applications where source is never stored in web session.

Since:
1.8 and 2.2
Author:
Jeff Miller
See Also:
Serialized Form

Constructor Summary
SimpleLazySelector()
          Constructs for use when SimpleLazySelector is base class of row that will contain lazy select fields.
SimpleLazySelector(R source)
          Constructs for use as delegate for row that will contain lazy select fields.
 
Method Summary
protected  void closeDatabase()
          Does nothing since Database from pendingLazySelects(Database) is resued.
protected  void openDatabase()
          Does nothing since Database from pendingLazySelects(Database) is resued.
 void pendingLazySelects(Database database)
          Saves reference to database for use in future lazy selects.
 
Methods inherited from class org.sormula.operation.cascade.lazy.AbstractLazySelector
begin, checkLazySelects, commit, getDatabase, getPendingLazySelectFields, getSource, initDatabase, initPendingLazySelectCascadeFields, isLocalTransaction, isPendingLazySelects, isUseTransaction, lazySelect, rollback, setDatabase, setUseTransaction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLazySelector

public SimpleLazySelector()
Constructs for use when SimpleLazySelector is base class of row that will contain lazy select fields. Typically the derived class is the one side of a one-to-many relationship or derived class has a reference to the other class in a one-to-one relationship. AbstractLazySelector.setUseTransaction(boolean) is true by default.


SimpleLazySelector

public SimpleLazySelector(R source)
Constructs for use as delegate for row that will contain lazy select fields. AbstractLazySelector.setUseTransaction(boolean) is true by default.

Parameters:
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 relationship
Method Detail

pendingLazySelects

public void pendingLazySelects(Database database)
                        throws LazyCascadeException
Saves reference to database for use in future lazy selects.

Specified by:
pendingLazySelects in interface LazySelectable
Overrides:
pendingLazySelects in class AbstractLazySelector<R>
Parameters:
database - perform lazy selects from this database
Throws:
LazyCascadeException - if error

openDatabase

protected void openDatabase()
                     throws LazyCascadeException
Does nothing since Database from pendingLazySelects(Database) is resued.

Specified by:
openDatabase in class AbstractLazySelector<R>
Throws:
LazyCascadeException - if error
Since:
1.9 and 2.3

closeDatabase

protected void closeDatabase()
                      throws LazyCascadeException
Does nothing since Database from pendingLazySelects(Database) is resued.

Specified by:
closeDatabase in class AbstractLazySelector<R>
Throws:
LazyCascadeException
Since:
1.9 and 2.3