sajad torkamani

In a nutshell

@UniqueEntity is a Symfony annotation used to validate at the application-layer that a particular field or fields is unique to an entity.

@UniqueConstraint is a Doctrine annotation used to validate at the database-layer that a particular field or fields is unique to a table. It will generate a unique index at the SQL level.

Which to use?

Use both. You want to validate at both the application and database layers.