TYPO3 Flow: Creating a unique model property using annotations

In order to create a unique property of a TYPO3 Flow model, just a uniqueConstraint like this:

...
/**
 * @Flow\Entity
 * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="code_unique", columns={"code"})})
 */
class Code {
...

In this case, the code_unique is only defining the name of the constraint and code is the model property that should be unique.

Easy – if you know how it works 😉

    • Adrian Föder
    • January 13th, 2015

    eine Annotation @ORM\Column(unique=true) an der betreffenden Property würde auch reichen und ist IMO besser lesbar 😉

  1. No trackbacks yet.