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.