This class manages the reuse of CompiledStatement objects for prepared
statements for a Database instance.
A compiled statement is registered by a session to be managed. Once
registered, it is linked with one or more sessions.
The sql statement text distinguishes different compiled statements and acts
as lookup key when a session initially looks for an existing instance of
the compiled sql statement.
Once a session is linked with a statement, it uses the uniqe compiled
statement id for the sql statement to access the statement.
Changes to database structure via DDL statements, will result in all
registered CompiledStatement objects to become invalidated. This is done by
setting to null all the managed CompiledStatement instances, while keeping
their id and sql string. When a session subsequently attempts to use an
invalidated (null) CompiledStatement via its id, it will reinstantiate the
CompiledStatement using its sql statement still held by this class.
This class keeps count of the number of different sessions that are linked
to each registered compiled statement, and the number of times each session
is linked. It unregisters a compiled statement when no session remains
linked to it.
Modified by fredt@users from the original by boucherb@users to simplify,
support multiple identical prepared statements per session, and avoid
keeping references to CompiledStatement objects after DDL changes which
could result in memory leaks. Modified further to support schemas.
author: boucherb@users author: fredt@users since: 1.7.2 version: 1.8.0 |