i'm playing a little bit with Symfony2 and Doctrine2.

I have an Entity that has a unique title for example:

```
class listItem
{
    /**
     * @orm:Id
     * @orm:Column(type="integer")
     * @orm:GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @orm:Column(type="string", length="255", unique="true")
     * @assert:NotBlank()
     */
    protected $title;

```

now i'm fetching a json and updating my database with those items:

```
$em = $this->get('doctrine.orm.entity_manager');

foreach($json->value->items as $item) {
    $listItem = new ListItem();
    $listItem->setTitle($item->title);
    $em->persist($listItem);
}

$em->flush();

```

works fine the first time. but the second time i'm getting an sql error (of course): `Integrity constraint violation: 1062 Duplicate entry`

sometimes my json file gets updated and some of the items are new, some are not.
Is there a way to tell the entity manager to skip the duplicate files and just insert the new ones?

Whats the best way to do this?

Thanks for all help. Please leave a comment if something is unclear

Edit:
-----

what works for me is doing something like this:

```
$uniqueness = $em->getRepository('ListItem')->checkUniqueness($item->title);
    if(false == $uniqueness) {
        continue;
    }

    $listItem = new ListItem();
    $listItem->setTitle($item->title);
    $em->persist($listItem);
    $em->flush();
}

```

`checkUniqueness` is a method in my ListItem Repo that checks if the title is already in my db.

thats horrible. this are 2 database queries for each item. this ends up about 85 database queries for this action.