Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
The one to many relation between comment and topic table table is represented in the following code .One to many and one to many is bidirectional . I used @OneToMany and @ManyToOne .
Code:
FetchType.LAZY
Means don't load the object until the get function is accessed .This saves memory and avoid unneeded hits.
Code:
cascade=CascadeType.ALL
Means one the referenced record deleted ( here topic) , all the other records use this reference is deleted .(here is comments)
Here the code example between the table "comment" and "topic" .