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