I'm not sure how to annotate the bellow classes correctly. What I'm trying to do is to have on the User entity, a list of roles for a mapped Asset.
@Entity
class Asset{
@Id @GeneratedValue(strategy = GenerationType.AUTO)
var id: Long = -1
}
@Entity
class Role {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
var id: Long = -1
}
@Entity
class User{
@Id @GeneratedValue(strategy = GenerationType.AUTO)
var id: Long = -1
???
var roles: Map<Asset, Set<Role>> = HashMap()
}
From what I discovered hibernate does not support a map of sets (link here). So I tried other options as an intermediate class like this.
But I'm struggling with the annotations. Can someone please tell what annotations I have to put on the three classes?
If someone knows a better approach instead of the map, to have the user roles by asset, please tell.