Table of Contents
SQLContainer
FreeformQuery
and FreeformStatementDelegate
Vaadin SQLContainer is a container implementation that allows easy and customizable access to data stored in various SQL-speaking databases.
SQLContainer supports two types of database access. Using
TableQuery
, the pre-made query generators will enable
fetching, updating, and inserting data directly from the container into a database
table - automatically, whereas FreeformQuery
allows the
developer to use their own, probably more complex query for fetching data and
their own optional implementations for writing, filtering and sorting support -
item and property handling as well as lazy loading will still be handled
automatically.
In addition to the customizable database connection options, SQLContainer also
extends the Vaadin Container
interface to implement more
advanced and more database-oriented filtering rules. Finally, the add-on also
offers connection pool implementations for JDBC connection pooling and JEE
connection pooling, as well as integrated transaction support; auto-commit mode is
also provided.
The purpose of this section is to briefly explain the architecture and some of the inner workings of SQLContainer. It will also give the readers some examples on how to use SQLContainer in their own applications. The requirements, limitations and further development ideas are also discussed.
SQLContainer is available from the Vaadin Directory under the same unrestrictive Apache License 2.0 as the Vaadin Framework itself.
The architecture of SQLContainer is relatively
simple. SQLContainer
is the class implementing the
Vaadin Container
interfaces and providing access to
most of the functionality of this add-on. The standard Vaadin
Property
and Item
interfaces
have been implementd as the ColumnProperty
and
RowItem
classes. Item IDs are represented by
RowId
and TemporaryRowId
classes. The RowId
class is built based on the primary
key columns of the connected database table or query result.
In the connection package, the
JDBCConnectionPool
interface defines the requirements
for a connection pool implementation. Two implementations of this interface
are provided: SimpleJDBCConnectionPool
provides a
simple yet very usable implementation to pool and access JDBC
connections. J2EEConnectionPool
provides means to
access J2EE DataSources.
The query package contains the
QueryDelegate
interface, which defines everything the
SQLContainer needs to enable reading and writing data to and from a
database. As discussed earlier, two implementations of this interface are
provided: TableQuery
for automatic read-write support
for a database table, and FreeformQuery
for customizing
the query, sorting, filtering and writing; this is done by implementing
relevant methods of the FreeformStatementDelegate
interface.
The query package also contains
Filter
and OrderBy
classes which
have been written to provide an alternative to the standard Vaadin container
filtering and make sorting non-String properties a bit more user friendly.
Finally, the generator package contains a
SQLGenerator
interface, which defines the kind of
queries that are required by the TableQuery
class. The
provided implementations include support for HSQLDB, MySQL, PostgreSQL
(DefaultSQLGenerator
), Oracle
(OracleGenerator
) and Microsoft SQL Server
(MSSQLGenerator
). A new or modified implementations may
be provided to gain compatibility with older versions or other database
servers.
For further details, please refer to the SQLContainer API documentation.