JPA-to-many, many-to-mapping

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/wxm994116/article/details/60135225

To avoid forget to write down these dots.


Case-to-many mapping entity when

@OneToMany(cascade = { CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY, mappedBy = "depart")
private Set<Employee> emps;

// generate getter / setter methods

// note that the above mappedBy corresponds to the number of entities you mean, you can see in the following


Case of many-to-time mapping entity


Guess you like

Origin blog.csdn.net/wxm994116/article/details/60135225