Problem Using Doctrine 2 Annotation @GeneratedValue (strategy = "AUTO")

Hope someone can help me. I have the following doctrine annotation:

/**
 * @var integer 
 *
 * @Column(name="code", type="integer", length=4)
 * @Id
 * @GeneratedValue(strategy= "AUTO")
 */
private $code;

Where code is the main key of my table. I want the code value to be set correctly (automatically) every time a row is inserted into a table.

I use Doctrine 2 and PostgreSQL, and the problem is this: To prepare the database in advance, I insert rows into the table using SQL commands directly in PgAdmin. Then I try to insert new rows, but this time through my program, and every time I try to insert this row, I get a primary key conflict until I tried as many times as I inserted rows with SQL commands before.

, 3 SQL-, 3 , 4- .

4 (, , SQL ), ?

!

+3
1

, , :

insert into table (code, ... ) values (1, ...)

. , Doctrine , . - 1, . , , 2. , .

, .

!

0

All Articles