Let's take a look at the simplest example: a class corresponds to a table.
There is such a class:address
Table structure:
CREATE TABLE ADDR (
Street VARCHAR (255) PRIMARY KEY,
City VARCHAR (255),
State CHAR (2),
ZIPCODE VARCHAR (10),
Deliv_ins CLOB
)
Mapping File Contents:
<orm>
<package name= "COM.XYZ" >
<class name= "Address" table= "ADDR" >
<field name= "Street" column= "Street"/>
<field name= "City" column= "City"/>
<field name= "state" column= "state"/>
<field name= "Zip" column= "ZIPCODE"/>
<field name= "Deliveryinstructions" >
<column name= "Deliv_ins" jdbc-type= "CLOB"/>
</field>
</class>
</package>
</orm>
Interpretation:
1.<package name= "COM.XYZ", the address of the package.
2.<class name= "Address" table= "ADDR" >,address the name of the corresponding table is ADDR.
3. The name of the column corresponding to the <field name= "Street" column= the/>,street attribute of "Street" is street.
4.<field name= "Deliveryinstructions" >
<column name= "Deliv_ins" jdbc-type= "CLOB"/>
</field>
In general, the Javatype string type is converted to JDBC varchar (depending on the results of different databases, such as Oracle is VARCHAR2), and we can define the type in the database for each field. The Deliveryinstructions property is mapped to a CLOB type column. You can also specify the length of each column, without specifying the default value for the database, such as varchar defaults to 256. City can be modified like this:
<field name= "City" >
<column name= "City" jdbc-type= "VARCHAR" Length= "the City"/>
</field>