Hi Nima, The DDL that you pasted seems correct to me.
Also, try comparing it to XML or annotation mappings if you are not sure about the right mapping format to use. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 22 January 2015 at 21:51, Nima Sadjadi <[email protected]> wrote: > > Hi, > > I have two entities, Credit and Client, 1:1 to each other. Credit is > owning side. Client may or may not have a Credit. When I want to sync db > via console, it gives this alter query, the second line is definitely > wrong. where should I look into to find the problem? I tried to validate > mappings and got no error, seems ok, so what and where should I look into > to see why it is giving the second query? It seems that system is confused > and treat it as inheritance instead of OneToOne? > > > 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; > > mapping in client entity: > > $metadata->mapOneToOne(array( 'fieldName' => 'credit', > 'targetEntity' => 'Entity\\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, > ), ) > > )); > > > mapping in credit entity: > > $metadata->mapOneToOne(array( 'fieldName' => 'client', > 'targetEntity' => 'Entity\\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. > -- 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.
