the hibernate many, many-to-many (annotation mode)

Configure-to-many:

@OneToMany(mappedBy="grade", cascade={ CascadeType.ALL })

Here Insert Picture Description
1, mappedBy, equivalent to the inverse = true, reverse, grade is more than one entity class attribute names
2, cascade cascade operation:
CascadeType.REMOVE : cascade delete
CascadeType.PERSIST : cascade saves
CascadeType.MERGE : Cascade update
CascadeType.REFRESH : cascading refresh
CascadeType.ALL : cascading all actions
configured many-to

@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="gradeId")

1, JoinColumn specified foreign key column
2, fetch delay loading strategy specified, the default is of EAGER, i.e. load immediately, can be set to LAZY

Examples
Here Insert Picture Description
Here Insert Picture Description

Published 34 original articles · won praise 6 · views 3644

Guess you like

Origin blog.csdn.net/qq_35986709/article/details/103501442