@UniqueConstraint annotation in Java

I have a Java bean. Now, I want to be sure that the field should be unique.

I am using the following code:

@UniqueConstraint(columnNames={"username"})
public String username;

But I’m getting some error:

@UniqueConstraint is dissallowed for this location

What’s the proper way to use unique constraints?

Note: I am using play framework.

12 Answers
12

Leave a Comment