Powered by SmartDoc

The jdbc.mapping option

A jdbc.mapping option specifies a mapping policy for XML-relational mapping.

Parameter

The jdbc.mapping option takes one of the following values as a parameter:

direct
Uses direct mapping.
index
Uses index mapping.

The default configuration is direct.

Direct mapping means that all slots are mapped to table columns directly.

Index mapping means that slots which are mapped naturally are mapped to table columns.

Artifact

The jdbc.mapping option generates no additional classes. The jdbc.mapping option just modified the behavior of Relaxer Table Objects.

The jdbc.mapping option adds no additional methods to Relaxer objects.

Example

List 12.4.3.1[jdbcMapping.rng] is a sample schema for the jdbc.mapping option.

jdbcMapping.rng
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <ref name="account"/>
  </start>
  <define name="account">
    <element name="account">
      <attribute name="accountNo">
        <data type="token"/>
      </attribute>
      <element name="balance">
        <data type="int"/>
      </element>
      <element name="owner">
        <data type="token"/>
      </element>
      <ref name="address"/>
      <zeroOrMore>
        <ref name="phone"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="address">
    <element name="address">
      <attribute name="zip">
        <data type="token"/>
      </attribute>
      <text/>
    </element>
  </define>
  <define name="phone">
    <element name="phone">
      <attribute name="area">
        <data type="token"/>
      </attribute>
      <data type="token"/>
    </element>
  </define>
</grammar>

Direct mapping

Execution of Relaxer with the jdbc.mapping option is as follows:

$ relaxer -jdbc -jdbc.mapping:direct jdbcMapping.rng

Because the default value of the jdbc.mapping option is true, execution of Relaxer as shown below has the same effect.

$ relaxer -jdbc jdbcMapping.rng

As a result, Relaxer generates 13 files:

List 12.4.3.1.1[account.ddl] is a DDL for the schema.

account.ddl
CREATE TABLE "account" (
	"accountNo" VARCHAR(32) NOT NULL,
	"balance" INTEGER NOT NULL,
	"owner" VARCHAR(32) NOT NULL,
	"address" VARCHAR(128) NOT NULL,
	"address_zip" VARCHAR(32) NOT NULL,
	"phone" VARCHAR(512)
)

Index Mapping

Execution of Relaxer with the jdbc.mapping option is as follows:

$ relaxer -jdbc -jdbc.mapping:index jdbcMapping.rng

Because the default value of the jdbc.mapping option is true, execution of Relaxer shown below has the same effect.

$ relaxer -jdbc jdbcMapping.rng

As a result, Relaxer generates 13 files:

List 12.4.3.2.1[account.ddl] is a DDL for the schema.

account.ddl
CREATE TABLE "account" (
	"accountNo" VARCHAR(32) NOT NULL,
	"balance" INTEGER NOT NULL,
	"owner" VARCHAR(32) NOT NULL,
	"address" VARCHAR(128) NOT NULL,
	"address_zip" VARCHAR(32) NOT NULL,
	"document" VARCHAR(8192) NOT NULL
)