you don't need @UniqueConstraint if you declare that composite key as your @EmbeddedId see this link for the example.
you only need a class to become it's composite id:
@Embeddable
public class SomeCompositeClass {
@Column(name = "SOME_ID_1")
private String someId1;
@Column(name = "SOME_ID_2")
private String someId2;
//getter, setter methods
}
then use it inside your entity to became its @EmbeddedId
:
@Entity
@Table(name = "YOUR_MAIN_TABLE")
public class YourMainTable {
@EmbeddedId
private SomeCompositeClass myCompositeId ;
/*setter getter methods */
}