Hibernate object class definition Summary

Source: Internet
Author: User

Hibernate object class definition Summary
1: Class header
@ Entity
@ Table (name = "tb_user ")


2: Primary Key
@ Id
@ GeneratedValue (strategy = GenerationType. IDENTITY)
@ Column (name = "id", nullable = false)
Private Long id;


Joint primary key
@ Table (name = "tb_msgtarget", uniqueConstraints = {@ UniqueConstraint (columnNames = {"msgbody_id", "registration_id "})})


3: String type field
@ Column (name = "registration_ids", nullable = false, length = 128)
Private String registrationIds;


4: int type field
@ Column (name = "msg_type", nullable = true, columnDefinition = "int (1) default 0 COMMENT 'notification method '")
Private int msgType;


5: Blob fields
@ Column (name = "file_content", nullable = true, columnDefinition = "Blob (16000000 )")
Private byte [] fileContent;


6: non-persistent Fields
If an attribute is not a field ing of a database table, you must mark it as @ Transient,
Otherwise, the annotation of the ORM framework is @ Basic by default.
@ Transient
Private String url_img;


7: foreign key Association
@ ManyToOne
@ JoinColumn (name = "device_id", referencedColumnName = "registration_id ")
Private Device device;
By default, the primary keys of the associated entities are generally used as foreign keys. If you do not want the primary key as the foreign key at this time, you need to set the referencedColumnName attribute.

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.