Representing Tables in XML¶
To represent tables, use the jdbcTable element. A table is a child of the resources element.
Table Hierarchy¶
The following hierarchy is used for jdbcTable elements when representing a table from the data source.
jdbcTable¶
The jdbcTable element represents a table or a copy of a table in the data source. A Domain design must reference all the tables it needs to access, including tables that you need to construct the Domain but do not want to expose to the end user. jdbcTable is a child of the resources element.
Note
The jdbcTable element is also used with different attributes to describe join trees. See Representing Joins in XML.
XML Attributes¶
Attribute |
Type | Description |
|---|---|---|
|
String | (Required) Identifier for the data source, as set in the |
|
String | (Required) Unique identifier for the table in the Domain design file. If you copy a table to join it multiple times, each copy has the same The id is a representation of the table name in the data source, with unsupported characters replaced by underscores. |
schemaAlias |
Name of the database schema in the data source. Required if the data source uses schemas.
|
|
datasourceTableName |
String | (Required) Literal name of the table in the data source. |
Child Elements¶
| Element Name | Description |
|---|---|
<fieldList> |
(Required) A container for the field elements in the table. Each jdbcTable element can contain only one fieldList element. |
<filterString> |
Expression that evaluates to true or false when applied to each row of values in the data source. For a table, the expression refers to columns using the field_name form of the column ID. See Representing Pre-filters in XML for more information. |
fieldList¶
fieldList is a container for one or more field elements.
In the Domain Designer, you can select only entire tables, not individual columns. In the XML design file, however, you can specify any subset of columns that you need.
Child Elements¶
| Element Name | Description |
|---|---|
<field> |
(Required) A column from the table specified in jdbcTable. |
field¶
The field element represents a column in the data source. The column must be from the table specified by jdbcTable. You must reference all the columns you use in the Domain, including columns that are used to construct the Domain but are not exposed to the end user.
XML Attributes¶
Attribute |
Type | Description |
|---|---|---|
fieldDBName |
String | Literal name of the column in the data source. |
id |
String | (Required) Identifier for the column. As in the JDBC model that the data source is based on, the The id is a representation of the column name in the data source, where unsupported characters replaced by underscores. |
type |
String | (Required) The Java type of the column, as determined from the data source by the JDBC driver. The available types are shown below. |
Supported Types¶
The following Java types are supported for the type attribute:
|
|
|
java.sql.Timestamp |
|
|
|
|
|
|
|
java.util.Date |
|
|
|
Unless you know the name and type of every column in the data source, it is often easier to select the tables you want in the Domain Designer and then export the XML design file. The Domain Designer accesses the data source to find the names of all tables and columns, as well as their types. You can then modify the exported design.
Note
If you have proprietary types in your database, the server may not be able to map its Java type from the JDBC driver. You can configure the mapping for proprietary types, as described in the JasperReports Server Administrator Guide.
Alternatively, you can override any mapping by specifying the type attribute for any given field in the XML design file. The server uses this Java type for the field, regardless of its mapping. If your proprietary type can't be cast in the specified type, the server raises an exception.