|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectnet.sf.eodsql.QueryTool
public class QueryTool
The QueryTool is used to construct an implementation of a
BaseQuery interface. There are two types of BaseQuery
that can be constructed with this class:
BaseQuery that locks a Connection
to the database (obtained via
getQuery(Connection, Class)). This type of
query will only allow one connected DataSet at a time,
the DataSet.disconnect() method, or the
Select.disconnected() flag may be used to get around this
limitation. Once a DataSet becomms disconnected, the
queries Select methods can be used again. Attempting to
call a method when the Connection is in use will result
in an IllegalStateException.
BaseQuery. These can be obtained
through the getQuery(DataSource, Class)
methods. The reason these queries are pool-friendly is that they
do not request a Connection from the
DataSource until a method is called, and they release
the connections one they are done with it. This also makes them
suitable for long-term storage as class-fields instead of local
variables.
QueryTool also has a notion of a "default"
DataSource, which can be set via the
setDefaultDataSource(javax.sql.DataSource) method.
The classes generated by this class are loaded via the
Proxy class. Effort is made to minimize the
amount of time it takes to create the query objects by caching structure
information, and lazy loading the actual method implementations.
The ClassLoader used for the implementation
classes is the ContextClassLoader.
The query classes are validated before any initialization of Proxy's is
done, if the query class violates any of the rules for creating
a BaseQuery the creation method will throw an
InvalidQueryException
Proxy,
Thread.getContextClassLoader()| Method Summary | ||
|---|---|---|
static
|
createQueryImplementation(Class<T> query)
Deprecated. use getQuery(Class) in preference to this method |
|
static
|
createQueryImplementation(Connection connection,
Class<T> query)
Deprecated. use getQuery(Connection, Class) in preference to this method |
|
static
|
createQueryImplementation(DataSource dataSource,
Class<T> query)
Deprecated. use getQuery(DataSource, Class) in preference to this method |
|
static DataSource |
getDefaultDataSource()
Returns the "default" DataSource if one has been set. |
|
static
|
getQuery(Class<T> query)
Returns an instance of a generated implementation for a specific BaseQuery class. |
|
static
|
getQuery(Connection connection,
Class<T> query)
Creates a new instance of a BaseQuery class with a specific
Connection. |
|
static
|
getQuery(DataSource dataSource,
Class<T> query)
Creates a new instance of a BaseQuery class with a reference
to the specified DataSource. |
|
static Map<Class,TypeMapper> |
getTypeMap()
Returns the Map that specifies how Java types should
be mapped to SQL types and back again. |
|
static void |
setDefaultDataSource(DataSource ds)
Sets the "default" DataSource for the VM. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void setDefaultDataSource(DataSource ds)
DataSource for the VM. This method must be
invoked before createQueryImplementation(Class) can be called, the
other createQueryImplementation methods are unaffected by the
default DataSource. This method may not be called with
null, and will throw an IllegalArgumentException
if the specified DataSource is null.
ds - the default DataSource for the VMpublic static DataSource getDefaultDataSource()
DataSource if one has been set.
If setDefaultDataSource has not been called with a
valid DataSource this method will return null.
DataSource for this VMsetDefaultDataSource(javax.sql.DataSource)@Deprecated public static <T extends BaseQuery> T createQueryImplementation(Class<T> query)
getQuery(Class) in preference to this method
Returns an instance of a generated implementation for a specific
BaseQuery class. After validating that the specified class
is a valid query class, this method will return a new implementation
of the requested BaseQuery with a reference to the specified
DataSource. Each query will keep track of any
Connections it opens, and force them closed when it's
BaseQuery.close() is called.
If the default DataSource has not yet been set, this method
will throw an IllegalStateException.
If the query class violates any of the rules for a
query, this method will result in an
IllegalArgumentException.
query - the BaseQuery to create an implementation of
BaseQuery
@Deprecated
public static <T extends BaseQuery> T createQueryImplementation(DataSource dataSource,
Class<T> query)
getQuery(DataSource, Class) in preference to this method
BaseQuery class with a reference
to the specified DataSource. Each query will keep track of any
Connections it opens, and force them closed when it's
BaseQuery.close() is called. If the DataSource is
null this method will throw an
IllegalArgumentException.
dataSource - the dataSource to obtain Connections fromquery - the BaseQuery to create an implementation of
BaseQuerycreateQueryImplementation(Class)
@Deprecated
public static <T extends BaseQuery> T createQueryImplementation(Connection connection,
Class<T> query)
getQuery(Connection, Class) in preference to this method
BaseQuery class with a specific
Connection. If the Connection is
null this method will throw an
IllegalArgumentException. The specified Connection
will be closed when the BaseQuery.close() method is called.
connection - the connection to use for the query classquery - the BaseQuery to create an implementation ofcreateQueryImplementation(Class)public static <T extends BaseQuery> T getQuery(Class<T> query)
Returns an instance of a generated implementation for a specific
BaseQuery class. After validating that the specified class
is a valid query class, this method will return a new implementation
of the requested BaseQuery with a reference to the specified
DataSource. Each query will keep track of any
Connections it opens, and force them closed when it's
BaseQuery.close() is called.
If the default DataSource has not yet been set, this method
will throw an IllegalStateException.
If the query class violates any of the rules for a
query, this method will result in an
IllegalArgumentException.
query - the BaseQuery to create an implementation of
BaseQuery
public static <T extends BaseQuery> T getQuery(DataSource dataSource,
Class<T> query)
BaseQuery class with a reference
to the specified DataSource. Each query will keep track of any
Connections it opens, and force them closed when it's
BaseQuery.close() is called. If the DataSource is
null this method will throw an
IllegalArgumentException.
dataSource - the dataSource to obtain Connections fromquery - the BaseQuery to create an implementation of
BaseQuerygetQuery(Class)
public static <T extends BaseQuery> T getQuery(Connection connection,
Class<T> query)
BaseQuery class with a specific
Connection. If the Connection is
null this method will throw an
IllegalArgumentException. The specified Connection
will be closed when the BaseQuery.close() method is called.
connection - the connection to use for the query classquery - the BaseQuery to create an implementation of
BaseQuerygetQuery(Class)public static Map<Class,TypeMapper> getTypeMap()
Map that specifies how Java types should
be mapped to SQL types and back again. This Map may be
modified directly to add new types to the system.
Map
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||