hibernate

Showing posts with label hibernate. Show all posts
Showing posts with label hibernate. Show all posts

The best way to map @OneToOne


@OneToOneThe best approach to bidirectional @OneToOne is to use @MapsIdStudent entity@Entity@Data@Table(name = "students")public class Student implements Serializable {     @Id     @GeneratedValue     private Integer id;     private...

The best way to map @ManyToMany


@ManyToManyMany to many relationships can be easily mapped by creating another table using @JoinTable as follows.Student entity@Data@Table(name = "Student")@Entitypublic class Student implements Serializable {     @Id     @GeneratedValue(strategy = GenerationType.AUTO)...

States of an object in Hibernate


Hibernate object statesThere are three statesTransient If the object just created, no primary key and not associate with a session, then the object is in the transient statePersistent If a session is open, the object is in the persistent stateDetached If a session is closed, the object...