Java knowledge 05 Hibernate primary key + annotation style

1, the primary key class must be serializable, and override equals and hashCode method  

    The primary key class Why serialize? If a plurality of such objects into memory at the same time, in a cluster system, if one of the servers is shutting down, needs to be written to memory objects to other servers. Meanwhile, if the server memory is full, you need to use virtual memory, which need to serialize the writes to the hard disk.

2 comment  

    @Entity
    the @Table (name = "XXXX")
    the @Column (.....)
     A. implementation manner: the primary key class annotated @Embeddable, the primary key object annotated @Id
     B. two implementations: in the primary key object reference annotated @EmbeddedId
     C. third implementation: field contains the primary key in the object, and which are annotated as @Id, and annotations @IdClass (primary key based on the object class .class )

3, examples  

 

Guess you like

Origin www.cnblogs.com/dshore123/p/11528059.html