10-hibernate Single-table operations-component Properties

Source: Internet
Author: User

Component properties:

An object of a property in an entity class that belongs to a user-defined class, such as an object in an entity class that is a custom class:

This address is a user-defined class.

The custom class address is defined as follows:

//Address class Public classAddress {PrivateString postcode;//Postal Code    PrivateString phone;//Telephone    PrivateString address;//Address         PublicAddress () {} PublicAddress (string postcode, string phone, address of string) {//super ();         This. Postcode =postcode;  This. Phone =phone;  This. Address =address; }     PublicString Getpostcode () {returnpostcode; }     Public voidSetpostcode (String postcode) { This. Postcode =postcode; }     PublicString Getphone () {returnphone; }     Public voidSetphone (String phone) { This. Phone =phone; }     PublicString getaddress () {returnaddress; }     Public voidsetaddress (String address) { This. Address =address; }}

The entity classes are modified as follows:

The test class is modified as follows:

The standard registration rules are as follows: Address represents the attribute name in the corresponding entity class , class represents the custom class name,

The following postcode represents a property name in a custom class that represents a field in the corresponding database.

Register in the Hbm.xml file as follows:

Query results after execution:

10-hibernate Single-table operations-component Properties

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.