I have two OneToOne entities, client is reverse side and credit is owning
side.
the identifier of client is auto-incrementing. and the identifer of credit
is not auto incrementing but is still primary.

strangely, when I want to update db, I get FK on both sides but FK should
be on credit table only:

I am stuck on this, please help.

ALTER TABLE credits CHANGE client_id client_id INT AUTO_INCREMENT NOT NULL;
ALTER TABLE credits ADD CONSTRAINT FK_3849450A19EB6921 FOREIGN KEY
(client_id) REFERENCES clients (client_id);
ALTER TABLE clients ADD CONSTRAINT FK_7996BA0019EB6921 FOREIGN KEY
(client_id) REFERENCES credits (client_id) ON DELETE CASCADE;
On Client entity, here is the info:
$metadata->mapField(array(
   'fieldName' => 'clientId',
   'columnName' => 'client_id',
   'type' => 'integer',
   'nullable' => false,
   'unsigned' => false,
   'comment' => '',
   'id' => true,
  ));
$metadata->mapOneToOne(array( 'fieldName' => 'credit',
                               'targetEntity' => 'Entities\\Credit',
                               'mappedBy' => 'client',
                 'cascade' => array( 0 => 'remove', 1 => 'persist', ),
                               'joinColumns' => array( 0 => array( 'name'
=> 'client_id',

'referencedColumnName' => 'client_id',

'nullable' => true,
                 'onDelete' => 'cascade',

'columnDefinition' => NULL,
                                                      ), )

                             ));

and on credit entity I have this:

$metadata->mapField(array(
   'fieldName' => 'clientId',
   'columnName' => 'client_id',
   'type' => 'integer',
   'nullable' => false,
   'unsigned' => true,
   'comment' => '',
   'id' => true,
  ));
$metadata->mapOneToOne(array( 'fieldName' => 'client',
                               'targetEntity' => 'Entities\\Client',
                               'inversedBy' => 'credit',
                               'joinColumns' => array( 0 => array( 'name'
=> 'client_id',

'referencedColumnName' => 'client_id',

'nullable' => true,

'columnDefinition' => NULL,
                                                      ), )

                             ));

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to