Bug #26365

Importing resources causes integrity constraint violation: 1062 Duplicate entry

Added by Julian Kleinhans over 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Should have
Category:
Resource
Start date:
2011-04-27
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

Example

$flagResource = $this->resourceManager->importResource('resource://Tutorials/Public/Images/Icons/Germany.png');
$languageModel = $this->objectManager->create('F3\Tutorials\Domain\Model\Language');
$languageModel->setName('German');
$languageModel->setImage($flagResource);
$this->languageRepository->add($languageModel);

and than

  $this->languageRepository->removeAll();

Problem:
the hash in the flow3_resource_resourcepointer doesnt delete

if i add the language again

$flagResource = $this->resourceManager->importResource('resource://Tutorials/Public/Images/Icons/Germany.png');
$languageModel = $this->objectManager->create('F3\Tutorials\Domain\Model\Language');
$languageModel->setName('German');
$languageModel->setImage($flagResource);
$this->languageRepository->add($languageModel);

an uncaught exception throws

#23000: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3bed18a6e887a13c69c7f17ef7a00bfaead3ba8d' for key 'PRIMARY'

This is the model

/**
 * A tutorial language
 *
 * @package Tutorials
 * @subpackage Domain/Model
 * @scope prototype
 * @entity
 */
class Language {

    /**
     * @var string
     * @validate Alphanumeric, StringLength(minimum = 1, maximum = 20)
     */
    protected $name;

    /**
     * @var \F3\FLOW3\Resource\Resource
     * @ManyToOne(cascade={"all"})
     * validate NotEmpty
     */
    protected $image;

    /**
     * Sets the languages name
     *
     * @param string $name
     * @return void
     */
    public function setName($name) {
        $this->name = $name;
    }

    /**
     * Returns the languages name
     *
     * @return string
     */
    public function getName() {
        return $this->name;
    }

    /**
     * Sets the original resource
     *
     * @param \F3\FLOW3\Resource\Resource $originalResource
     * @return void
     */
    public function setImage(\F3\FLOW3\Resource\Resource $image) {
        $this->image = $image;
    }

    /**
     * Returns the original resource
     *
     * @return \F3\FLOW3\Resource\Resource $image
     */
    public function getImage() {
        return $this->image;
    }

}

#1

Updated by Karsten Dambekalns about 10 years ago

  • Subject changed from Persistence: Integrity constraint violation: 1062 Duplicate entry to Importing resources causes integrity constraint violation: 1062 Duplicate entry
  • Category changed from Persistence to Resource
  • Status changed from New to Resolved
  • Assignee set to Sebastian Kurfuerst
  • Target version set to 1.0 beta 1
  • % Done changed from 0 to 100

Also available in: Atom PDF