Reputation: 1
I was reading this great tutorial https://www.callicoder.com/spring-boot-spring-security-jwt-mysql-react-app-part-1/
I have an entity "User" which I don't need a table for in the db, the User info will be retrieved from an API. The user has a relationship with an entity that has a db table "Role".
How can I use spring boot hibernate to build such a case:
public Class User{
private Long id;
.
.
.
@ManyToMany
Set<Role> roles;
}
Upvotes: 0
Views: 1692
Reputation: 847
I think you cannot make relations with a non managed entity, but you can write a service manually, and load the user and the roles for it separately (the user is a REST request, and the role is a query)
Upvotes: 1
Reputation: 2685
I believe you will need a Service (and Repository), which will retrieve, from the DB, the Role
s associated with User
& then populate them in the User
.
Upvotes: 0