This note is about the problems that I met while using Hibernate.
Generated Value
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
Mapping
// One to one
@OneToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH})
@JoinColumn(name = "memberId")
- CascadeType.PERSIST : means that save() or persist() operations cascade to related entities.
- CascadeType.MERGE : means that related entities are merged into managed state when the owning entity is merged.
- CascadeType.REFRESH : does the same thing for the refresh() operation.
- CascadeType.REMOVE : removes all related entities association with this setting when the owning entity is deleted.
- CascadeType.DETACH : detaches all related entities if a “manual detach” occurs.
- CascadeType.ALL : is shorthand for all of the above cascade operations.
竟然无法拒绝你的打赏
