Hi,
I have an User with 2 columns "username" and "status" as uniqueconstraints on table level as you can see in below example code. That seems to work fine.
The status column can contain "Active" or "Inactive".
I need to have multiple rows in User table with same username and the status value "Inactive", but only one row with the username and status "Active". Like below example:
User table
--------------------------------
ID Username Status
1
xx@xx.com Active (Only if the status is active should be unique constaint)
2
xx@xx.com Inactive
3
xx@xx.com Inactive
.....
--------------------------------
Code example:
-----------------
@Table(name = "user", uniqueConstraints=@UniqueConstraint(columnNames = {"username","status"}))
public class User extends BaseObject implements Serializable, UserDetails {
....
}
I hope some can help....
-taltun