Ofcause有可能)) 例如:
实体:
@Entity
public class Content {
//...
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
private final Set<Category> categories = new HashSet<>();
//...
}
@Entity
public class Category {
//...
@ManyToMany(mappedBy = "categories")
private final Set<Content> contents = new HashSet<>();
//...
}
库:
@RepositoryRestResource(collectionResourceRel = "contents", path = "contents")
public interface Content extends JpaRepository<Content, Long> {
}
@RepositoryRestResource
public interface Category extends JpaRepository<Category, Long> {
}
见我example和tests。
它有点混乱,你可以发布一些你的代码? – techtabu
如果答案是有用的,不要忘记接受/ upvote它。 – Cepr0