6.2.1 inheritance ing: Use the inheritance ing of the joined-subclass Element

Source: Internet
Author: User

When this ing is used, the parent class instance is stored in the parent class table, while the Child class instance is stored in the parent class table and the Child class table. Because the subclass instance is also a special parent class instance, it must also contain the attributes of the parent class instance.Store the attributes that are common to the Child class and the parent class in the parent class table, and the attributes added to the Child class are saved in the Child class table.

In this ing policy, the classifier column is not required, but the <key... /> element ing has a primary key ------ this primary key column will also refer to the primary key column of the parent table.

Person. HBM. xml:

<? XML version = "1.0"?> <! Doctype hibernate-mapping public "-// hibernate/hibernate DTD ing DTD 3.0 // en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 

Run personmanager. Java to view the database:

When you need to query a record with ID 5, Hibernate will query the data with ID 5 from the persons table and query the records with ID 5 in the customer table. Concatenates two records into one instance. Of course, this concatenation is done through a join SQL statement ------ this is also the reason why this ing policy is called joined-subclass.

UseJoined-subclassInherits the ing policy whenProgramWhen querying subclass instances, You need to query across multiple tables. The number of tables to be crossed depends on the number of parent classes in the subclass ------ this is because the data of the subclass is stored in multiple parent tables in sequence. Because of this policy,Therefore, the inheritance ing policy of joined-subclass has a certain impact on query performance.

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.