Some more annotations in hibernate
Hi Everyone, in this blog post I am writing more about annotations used in hibernate. I hope everyone has seen my previous post about hibernate annotations - Basic Hibernate Annotations.
1) @Basic - It is the simplest type of mapping to a database column.If basic annotation is not specified for a field or property, the default values of basic annotation will apply.
2) @Transient - Specifies that the field or the property cannot be persisted.
3) @Temporal - Must be specified for persistent fields or properties of type and Date and Calendar.
4) @Lob - Used for persisting a large object to a database.
5) @Embeddable - The persistent properties or fields of the embedded object is mapped to the database table for the entity.
6) @Embedded - Specifies a field or persistent property of an entity whose value is an instance to an embeddable class.
7) @EmbeddedId - Applied to a field or persistent property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class.
8)@AttributeOverride - Helps in reconfiguring all attributes. Overrides the mapping of a Basic property or field or Id.
9) @AttributeOverrides - Overrides multiple properties or fields. @AttributeOverride is written inside @AttributeOverrides.
10) @ElementCollection - Marks entire collection object to be persisted.
11) @JoinTable - It is used in the mapping of associations. Mainly used in the mapping of many-to-many and one-to-many associations. It is not mandatory to use this annotation.
12) @JoinColumn - Specifies a column for joining an entity association or element collection.
13) @CollectionId - It is hibernate specific annotation. Describes an identifies column for a bag (set, list, map).
14) @GenericGenerator - Allows to define an hibernate specific id generator. It is also a hibernate specific annotation.
15) @Type - It is a hibernate specific annotation. @Type overrides the default hibernate type used. It is not mandatory to use type annotation.
16) @TypeDef - It is a hibernate specific annotation. This allows you to declare type definitions.
17) @OneToOne - Used for one to one mapping. It defines a single valued association to another entity that has one-to-one multiplicity. It maps a foreign key column.
18) @OneToMany - Used with collections list. Used for one to many mapping. It specifies a many valued association with one-to-many multiplicity.
19) @ManyToOne - Used for many-to-one mapping. Defines a single valued association to another entity class that has many-to-one multiplicity.
20) @ManyToMany - Used for many-to-many mapping. Defines a many valued association with many-to-many multiplicity.
I hope this post gave you a better idea about hibernate annotations. Please comment below if you have any comments/suggestions. In my future posts I will be writing programs about most of the annotations described above. Please check that out also.
Thank you for reading the post.
Similar posts
1) Basic hibernate annotations.
2) @Table and @Column annotations.
1) @Basic - It is the simplest type of mapping to a database column.If basic annotation is not specified for a field or property, the default values of basic annotation will apply.
2) @Transient - Specifies that the field or the property cannot be persisted.
3) @Temporal - Must be specified for persistent fields or properties of type and Date and Calendar.
4) @Lob - Used for persisting a large object to a database.
5) @Embeddable - The persistent properties or fields of the embedded object is mapped to the database table for the entity.
6) @Embedded - Specifies a field or persistent property of an entity whose value is an instance to an embeddable class.
7) @EmbeddedId - Applied to a field or persistent property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class.
8)
1) Basic hibernate annotations.
2) @Table and @Column annotations.
Hibernate Training Institutes in Chennai | Hibernate Online Training | Hibernate Training in Chennai
ReplyDelete