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>
	<fieldList> (1)
		<field> (1...n)
	<filterString> (0...n)

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.

The jdbcTable element is also used with different attributes to describe join trees. See Representing Joins in XML.

XML Attributes

Attribute

Type

Description

datasourceId

String

(Required) Identifier for the data source, as set in the id attribute of jdbcDataSource. When creating a design file, this alias may be any name you choose, but it must be identical for all tables and derived tables. When uploading the file, the datasourceId automatically becomes the alias associated with the data source defined for the Domain.

id

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 datasourceId, schemaAlias, and datasourceTableName but must have a different id. To set a table id in the Domain Designer, right-click the table and select Rename Table from the context menu.

The id XML attribute can contain alphanumeric characters along with any combination of the following: @#$^`_~? It cannot start with a digit. When generated via the Domain Designer, 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.

For schemaless data sources, such as MySQL, schemaAlias is not required.
For schema-based data sources, such as PostgreSQL and Oracle, the name is the literal name of the schema in the data source, for example, public.
For schemaless data sources within a virtual data source, the schema name is of the form dataSourcePrefix, where dataSourcePrefix is the data source prefix defined when the virtual data source was created. For example, FoodmartDataSource.
For schema-based data sources within a virtual data source, the name is in the form dataSourcePrefix_schema, where dataSourcePrefix is the data source prefix defined when the virtual data source was created. For example, FoodmartDataSource_public.
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 id must be unique within the jdbcTable, but not necessarily within the Domain.

The id XML attribute can contain alphanumeric characters along with any combination of the following: @#$^`_~? It cannot start with a digit. When generated via the Domain Designer, 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.lang.Boolean

java.lang.Byte

java.lang.Character

java.lang.Double

java.lang.Float

java.lang.Integer

java.lang.Long

java.lang.Short

java.lang.String

java.math.BigDecimal

java.sql.Date

java.sql.Time

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.

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.