I want to convert my application to support multi-tenancy using shared tables (i.e. every table gets a tenant id). Obviously, I would not be able to use @Column(unique = true)
any more, because it would enforce uniqueness across all tenants, which I don't want.
I'm using Glassfish 3.1.1 with EclipseLink. Is there a way make @Column(unique = true)
force uniqueness per tenant (rather than per table). Or do I have to enforce this in the business logic?
It is also possible to specify uniqueness constraint on then @Table
annotation, e.g.
@Table(name = "USERS", uniqueConstraints = @UniqueConstraint(columnNames = {"TENANT_ID", "username"}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With