Interpretation of the JDO specification ORM (i)

Source: Internet
Author: User

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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.