C H A P T E R  29

JDBC SQL Query Model

The JDBC SQL Query Model allows developers to use one or more RDBMS tables as the backing datastore for the model. This allows display fields to be bound to columns in the database tables. All of the SQL operations can be performed using the query model: select (including multi-table joins), insert, update, and delete.

Property Name

Description

Notes

Data Source

The JDBC datasource name that will be used to obtain a connection from the J2EE container.

Req

Modifying Query Table

The name of the table that will be used when generating modifying queries (insert, update, delete). The model may use several tables for the select query but may only use one for modifying queries.

 

Name

The class name of the component.

Req

Select SQL Template

The SQL select statement template used to construct SQL SELECT statements for a retrieve operation. Typically, there is a where token ("__WHERE__") at the end of this statement that is replaced by a where clause that is constructed dynamically at runtime by the component.

 

Static Where Criteria

The where clause that is used with every SQL operation (except insert).

 


Fields

Property Name

Description

Notes

Column Name

The actual name of the column in the table to which the model field maps.

Req

Computed Field

True if If the model field is mapped to a computed field (a SQL aggregate function). Default setting is false.

 

Empty Formula

Specifies a SQL formula that provides a value if the field has no value, and only if the Empty Value Policy property is set to Use Formula.

 

Empty Value Policy

The policy used to provide a value for the field during an update operation. Choices are Exclude, Send Null, and Use Formula. Default setting is Exclude.

 

Field Type

The Java class type of the model field (java.lang.String, java.lang.Integer, java.lang.Boolean, etc.).

Req

Insert Formula

Specifies a SQL formula that provides a value if the field has no value, and only if the Insert Value Source property is set to Use Formula.

 

Insert Value Source

The policy used to provide a value for the field during an insert operation. Choices are Application, Database, and Use Formula. Default setting is Application.

 

Key Field

Specifies that the column to which the model maps is a key field or not. This property is required to be set if this model will be used for update, insert or delete behavior. When creating a Query Model using the wizard, it is not always possible for the key fields to be found in the JDBC driver metadata. For instance, PointBase datasources often fail to reveal key field indications while Oracle datasources work very consistently. If this field is not set and the update, insert or delete behavior is invoked, it may lead to a SQL exception.

 

Name

The logical name of the model field.

Req

Qualified Column Name

The fully qualified name (<table>.<column>) of the column to which the model field maps.

Req

Supported Operations

The SQL operations in which the model field will participate: Select, Insert, Update, and Delete. Default setting is Select, Insert, Update, and Delete.