One of the cores of hibernate: use the object relation to map the set algebraic relational
database :
1. There is a table structure.
2. There are N columns in each row of data on the table, and the data on the N columns has a type.
3. There are associated fields between each table as the existence of an association relationship.
4. . . . .
Java class: object type relationship
1. There is a class exists
2. Each instance object of a class has M class attributes, and M class attributes have type
3. There may be references to other classes in each class.
4. . . . .
It can be seen from the above that there is a similar relationship between java classes and database tables. Java classes
and .
The above only knows that this kind of mapping can be established. If you have a more specific understanding, just look at the hibernate mapping
file . This is an xml file that describes the mapping. Of course, some mappings are now implemented
in , we have to see them in the mapping entity class. Here I still focus on the xml mapping file to learn. Look at the nodes in the xml
file, what does each node mean. You can know
the .
1.DOCTYPE information
DTD information.
2.hibernate-mapping
has shema, loading strategy (lazy or non-lazy, etc.), package and other information
3.class
has a lot of information about tabl attributes and update strategies, and configuration information for data loading.
Such as table properties, name properties, dynamic-update properties, lazy and so on.
4.id
defines the mapping of attributes to the primary key of the database table.
1.generator sub-element: used to generate a unique identifier for the instance of the persistent class.
2. Different identifier generators.
5.composite-id
defines multiple attributes to the joint primary key.
6.property
defines the persistent properties of javabean style.
7.many-to-one
defines a common association with another persistent class. Typically a foreign key refers to the primary key of the target table.
8. one-to-one
One-to-one relationship.
9.. . . . . . .
TODO
hibernate learning
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326885180&siteId=291194637
Recommended
Ranking