Show Table of Contents
31.13.3. Mapping
A
type-mapping is simply a set of mappings between Java class types and database types. A set of type mappings is defined by a set of mapping elements, the content model for which is shown in Figure 31.19, “The jbosscmp-jdbc mapping element content model.”.

Figure 31.19. The jbosscmp-jdbc mapping element content model.
If JBoss cannot find a mapping for a type, it will serialize the object and use the
java.lang.Object mapping. The following describes the three child elements of the mapping element:
- java-type: This required element gives the fully qualified name of the Java class to be mapped. If the class is a primitive wrapper class such as
java.lang.Short, the mapping also applies to the primitive type. - jdbc-type: This required element gives the JDBC type that is used when setting parameters in a JDBC
PreparedStatementor loading data from a JDBCResultSet. The valid types are defined injava.sql.Types. - sql-type: This required element gives the SQL type that is used in create table statements. Valid types are only limited by your database vendor.
- param-setter: This optional element specifies the fully qualified name of the
JDBCParameterSetterimplementation for this mapping. - result-reader: This option element specifies the fully qualified name of the
JDBCResultSetReaderimplementation for this mapping.
An example mapping element for a short in Oracle9i is shown below.
<jbosscmp-jdbc>
<type-mappings>
<type-mapping>
<name>Oracle9i</name>
<!--...-->
<mapping>
<java-type>java.lang.Short</java-type>
<jdbc-type>NUMERIC</jdbc-type>
<sql-type>NUMBER(5)</sql-type>
</mapping>
</type-mapping>
</type-mappings>
</jbosscmp-jdbc>

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.