Hibernate-inheritance ing

Source: Internet
Author: User

There are three types of inheritance mappings for hibernate: subclass, joined-subclass, and union-subclass.

These three methods have their own capabilities and can play an ineffective role in situations where they cannot.

1. subclass: a large table

Discriminator)

 
 
  
  
   
   
  
  
  
  
  
     
  
  
   
   
   
   
  
  
  
   
Discriminator-value= "Employee">
   
   
   
   
   
   
   
    
    
   
   
   
    
Discriminator-value= "Manager">
    
    
    
    
     
     
    
   
  
  
  
   
Discriminator-value= "Customer">
   
   
   
   
  
 

All fields are in a large table and can be used for statistical analysis.

2. joined-subclass parent-child table

To use this policy, you must use The element maps the primary keys of the Parent and Child classes, Data columns mapped to elements are both primary key columns and foreign key columns.

 
 
  
  
   
   
  
  
  
  
  
  
   
   
   
   
  
  
  
   <
   KeyColumn = "employee_id"/>
   
   
   
   
   
   
   
    
    
   
   
   
    
    
    
    
    
    
     
     
    
   
  
  
  
   <
   KeyColumn = "customer_id"/>
   
   
   
  
 

A large table cannot be infinitely large. To a certain extent, a word table must be produced.

3. union-subclass classification function table

Table sharding by column enables each table to be oriented to one category, that is, it can be used independently or linked together to form a large table.

 
 
  
  
   
   
  
  
  
  
  
  
   
   
   
   
  
  
  
   
   
   
   
   
   
   
    
    
   
   
   
    
    
    
    
     
     
    
   
  
  
  
   
   
   
  
 


Summary:

Second in life, second in life, fourth in life, and four in Vientiane. The top-level tables are suitable for global statistics and are not suitable for presentation. The bottom-level tables are suitable for presentation of various representations, however, it is difficult to control the overall situation.



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.