1. Inheritance correlation mapping 1.1 inheritance mappings to multiple tables
Configuration:
<class name= "Product" ....>
....
<joined-subclass name= "" table= "" >
<key column= "t_product_id"/>
<property .../>
</joined-subclass>
</class>
Basic operation:
Save: Hibernate will be based on the specific type (book ring computer)
To determine which child table evaluates into, the parent table must be evaluates into
Delete: Hibernate will be based on the specific type (book ring computer)
To determine which child table to delete, the parent table must be deleted
Query subclasses from book:hibernate correlate queries t_product and T_book
querying the parent class from Product:hibernate will correlate the query t_product and all the child tables
The returned object is of a specific subclass type (can be forced to transform)
Query parent table data only, not associated child table
Select New Product (P.id, P.name, P.price) from Product p
1.2 Inheritance mappings to 1 table configurations: <class name= "Question" ....>
<discriminator type= "string" column= "T_type"/>
....
<subclass name= "Choicequestion" discriminator-value= "C" >
<property .../>
</subclass>
</class>
Action: Save: Hibernate will be based on type (which subclass)
To evaluates cookbook the value of the corresponding differentiator field
Fetch: Hibernate chooses the value of the Differentiator field
Which subclass is used to encapsulate and return data
Note: <discriminator type= "string" column= "T_type"/> A differentiator, equivalent to "watershed", which tells Hibernate which attribute is used to distinguish between classes that are not identical.
Discriminator-value= "C" with <discriminator type= "string" column= "T_type"/> To use, here write C means, if the user evaluates into the choice of the problem, the T_type value is C If the user evaluates into a question and answer question, the T_type value is E
3.one-to-many (List) * * Configuration: <list name= "Persons" cascade= "all" >
<key column= "t_team_id"/>
<list-index column= "T_turn" base= "0"/>
<one-to-many class= "Person"/>
</list>
Operation
One-to-many of the same set; however, inverse= "true" does not require a reverse association
Welcome everybody to discuss the study together!
Useful Self-collection!
Record and share, let you and I grow together! Welcome to my other blogs, my blog address: Http://blog.csdn.net/caicongyang