Useful Annotation for Model Class

In out previous post we have see how we can change the table name and the Model name using the

@Entity (name=”TABLE_NAME“)  and @Column (name=”COLUMN_NAME“)  

Here when we use the @Entity (name=”TABLE_NAME“) the entity name  also gets changed,so if we want to change only the table then use


suppose we have a field, we do not want to save it so we can mark it as static or transient
The hibernate way to not save that field is @Transient
@Transient  over the field.

Next for date field the hibernate maps it to the hibernate date which will give the time with timestamp.

Suppose if we want only the date to be saved without the time stamp


Another important annotation is to have a coloumn of 255 characters,but suppose we want to save a huge text then in that case use

@Lob to have coloumn lenght more than 255


Share :Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Comments are closed