Hibernate Tutorial - Part II
For part I refer: Hibernate tutorial Part - I In this post we will see how the entity mapping is done. Lets take an example of a library management application for simplicity and take a look at the various possible mappings. Lets say we need to create an entity 'Book'. We will create a Book POJO. This will be mapped to a table named 'Book'. The book table will have the following columns. BOOK_ID (Primary Key, Type: Number) driven by sequence book_id_seq BOOK_NAME (Type: Varchar2(50) PUBLISH_DATE (Type: Date) BOOK_PREVIEW (Type: clob) The Book class with entity annotations will be as below: @Entity @Table(name="book") @org.hibernate.annotations.Entity( dynamicUpdate = true ) public class Book implements Serializable{ private static final String BOOK_SEQUENCE = "book_id_seq"; @Id @Column(name="BOOK_ID") @SequenceGenerator( name=BOOK_SEQUENCE, sequenceName=BOOK_SEQUENCE)