1

im getting this error while trying to insert an entity in symfony2 with doctrine2,

/**
 * Moneda
 *
 * @ORM\Table(name="moneda")
 * @ORM\Entity
 */
 class Moneda
 {
     /**
     * @var integer
     *
     * @ORM\Column(name="moneda_id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="SEQUENCE")
     * @ORM\SequenceGenerator(sequenceName="moneda_moneda_id_seq", allocationSize=1,initialValue=1)
     */
     private $monedaId;

I`ve check my database to check any typo erros but everything is in order so i don´t know what is wrong here so please any help will be appreciated.

this is the exception

An exception occurred while executing 'SELECT NEXTVAL('moneda_moneda_id_seq')':

SQLSTATE[42P01]: Undefined table: 7 ERROR: no existe la relación «moneda_moneda_id_seq» LINE 1: SELECT NEXTVAL('moneda_moneda_id_seq')

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
metalvarez
  • 606
  • 1
  • 8
  • 14

1 Answers1

1

I have had the same issue before. You must include the schema name while referring to the sequence. So try using something like this when defining your sequence:

@ORM\SequenceGenerator(sequenceName="schema_name.moneda_moneda_id_seq", allocationSize=1,initialValue=1)

This is what solved my issue. Hopefully it will work for you as well.

Sehael
  • 3,678
  • 21
  • 35