JPA UniqueContraint in Inner class
<p>I have a question about JPA uniqueConstraint. </p>

<p>I have a PlayerJPA class with a uniqueConstraint in a (String) Nickname field but I want to add a constraint to the email field which is in a inner object : PersonalInformations.
(I don't want that two players have the same personalInformations)</p>

<pre><code>        @NamedQueries({
        @NamedQuery(name = "player.findAll", query = "select p from PlayerJPA p"),
        @NamedQuery(name = "person.removeAll", query = "delete from PlayerJPA "),
        @NamedQuery(name = "person.findByEmail", query = "select p from PlayerJPA p where p.personalInformations.email= :email"),
        @NamedQuery(name = "person.deleteByEmail", query = "delete from PlayerJPA P where p.personalInformations.email= :email")}
    )

    @Entity
    @Table( name = "PLAYER",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"NICK_NAME", "EMAIL"})})
    @XmlRootElement
    @XmlAccessorType(value = XmlAccessType.FIELD)
    @CascadeOnDelete
    public class PlayerJPA implements IPlayer {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name ="ID")
    private long id;


    @Column(name = "NICK_NAME")
    @NickName
    private String nickName;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "EMAIL")
    private PersonalInformationsJPA personalInformations;

    public PlayerJPA(){

    }

    public long getId() {
        return id;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public PersonalInformationsJPA getPersonalInformations() {
        return personalInformations;
    }

    public void setPersonalInformations(PersonalInformationsJPA personalInformations) {
        this.personalInformations = personalInformations;
    }

    @Override
    public String toString() {
        return display();
    }
    }
</code></pre>

<p>The problem is that it doesn't work with the line : </p>

<pre><code>  @Table( name = "PLAYER",
    uniqueConstraints = {@UniqueConstraint(columnNames = {"NICK_NAME", "EMAIL"})})
</code></pre>

<p>Do you know how can I do this  ? </p>

<p>Thanks you a lot !</p>