I am using hibernate with postgresql and I have following problem. Having a class Contest and Entry:
public class Contest{
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Type(type = "uuid-binary")
private UUID uuid;
@OneToMany(mappedBy="contest")
private List<Entry> entries;
@Column(name = "status")
private ContestStatus status;
...
public class Entry{
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Type(type = "uuid-binary")
private UUID uuid;
@ManyToOne()
@JoinColumn("contest")
private Contest contest;
@Column(name = "status")
private EntryStatus status;
I am using SCHEMA multitenancy and every user will have its own schema, but I do not want any user can create contest. That is something only admin can do. Assume we have admin user with admin_schema, and user "user123" with schema user123_schema wants to join to the contest which is available in Contest table of admin_schema. So, I would need something like this in Entry table:
@ManyToOne(schema="admin_schema")
@JoinColumn("contest')
Contest contest;
I know that "schema" property does not exist in @ManyToOne but just trying to show what I am trying to accomplish. Is there some way to do it? It does not seem to me like something that can be done, but wanted to check it before doing it on different way