Hibernate All Annotations – Tutorials & Examples

Hibernate All Annotations – Tutorials & Examples


This annotation can be used for the joining tables, by default it is not even necessary with hibernate, but if your intermediate joining table needs any other addtional columns to be added, then you must have @Embeddable annotated class.



This is the main annotation to link your class with your tables.


public class Coupon extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;

@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "coupon_id")
private Long couponId;

private String couponTitle;

@Column(columnDefinition = "varchar(3500)")
private String couponDesc;

// setters & getters for all the fields


  • coupon table will be mapped to this entity class
  • And maps all the three variables mentioned here to the respective columns in the coupon table.
  • if name attribute used inside @Column then the same name should be matched with your table column name.


For couponTitle no @column annotation and no name attribute, so by default, inside your entity class even if you don’t mention the @column it considers all the fields as columns and if the name attribute is not mentioned then it takes the default name, in this case coupon_title (as couponTitle) mentioned in camelcase.

48 total views, 2 views today

About: Mirthbees

Blogger, Innovator, Developer and Enterpreneur. Founder of GuruRecharge, Readymade online recharge script. Lead Developer in Bookrate.in