score:0

multiple things :

first, i can see a potential typo issue in what you've shown so far as in the table constraint annotation you reference to the column "language_id" ( singular ) whereas in your uniqueentity annotation you reference to the fiel "languages" ( plural ), so maybe try to double check your field / column definition.

the 2 ways you are trying to create your constraint have different purposes :

@orm\uniqueconstraint

is meant to generate schema changes in the database by adding a sql unique constraint. doing this enforces your database engine to check every entry in the said table and generate an error ( exemple : "error #1062" for mysql ) which can be relayed by the pdo into your php output.

@uniqueentity

on the other hand, uniqueentity is meant to validate your php entity ( doing a $form->isvalid() for exemple ) by firing a select statement against your database and checking if there are any results similar to the submitted values.

point is, reading carrefully and understanding the exception you are getting back will help you understand which constraint exactly causes the issue and finding the cause (is it an issue with the datas already in base ?).

moreover, depending on what you need to do, you may not need to include the 2 constraints, and only use the @uniqueentity or the @uniqueconstraint.

edit :

you could try to use the repositorymethod option to enforce the request used for validation by creating your own repository method.

hope this helps


Related Query

More Query from same tag