5--Basic usage of Hibernate--5 1 requirements for persistence classes

Source: Internet
Author: User

1. Provide a parameterless constructor: All persisted classes should provide a parameterless constructor, which may not take the public access control. Hibernate can use Constructor.newinstance () to create an instance of a persisted class as long as the parameterless constructor is provided. Typically, for hibernate to generate proxies at run time, the constructor's access control modifier is at least the package courseware, and is greater than or equal to the default access control character.

2. Provide an identity attribute: The host field that identifies the attribute that typically maps a database table. This property can be called any sensible, and its type can be any basic type, basic type of wrapper type, java.lang.String or java.util.Date. If you use a federated primary key for a database table, you can even use a user-defined class that uses these types of properties. Of course, instead of specifying any identity attribute, you can map multiple normal properties directly to a federated primary key in persisted annotations, but this is not usually recommended.

Tips:

Although hibernate allows you to use the basic type of 8 as the Identity property Hu type, this is not convenient in many places, so it is recommended to use the base type wrapper type as the type of the identity attribute.

5--Basic usage of Hibernate--5 1 requirements for persistence classes

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.