Le 08/05/2011 00:38, user123 a écrit :
Hi all,
I'm very new to symfony 1.x and symfony 2.0.I have state and customer
entity in different bundles. I just want to add one-to-one relation
between state and customer. Here is the my entities:
/**
  * @orm:Entity
  */
class Customer
{
     /**
      * @orm:Id
      * @orm:Column(type="integer")
      * @orm:GeneratedValue(strategy="AUTO")
      */
     protected $id;

     /**
      * @OneToOne(targetEntity="State")
      * @JoinColumn(name="state_id", referencedColumnName="id")
      */
     protected $state;

}

/**
  * @orm:Entity
  */
class State
{
     /**
      * @orm:Id
      * @orm:Column(type="integer")
      * @orm:GeneratedValue(strategy="IDENTITY")
      */
     protected $id;

     /**
      * @orm:Column(type="string", length="50")
      */
     protected $name;
}

Here is my config.yml:
doctrine:
     dbal:
         driver:   %database_driver%
         host:     %database_host%
         dbname:   %database_name%
         user:     %database_user%
         password: %database_password%

     orm:
         auto_generate_proxy_classes: %kernel.debug%
         mappings:
             FogCustomerBundle: { type: annotation, dir: Entity/ }
             FogMainBundle: { type: annotation, dir: Entity/ }


After I generate getters and setters I run php app/console
doctrine:schema:create command. It's working but relation field does
not generated automatically. Why? Am I forget any step? Can guys
please help me?

It has to be /@orm:OneToOne/ and /@orm:Joincolumn/
*All* Doctrine annotations have to be prefixed with /orm:/ in a Symfony project, not only some of them.

--
Christophe | Stof

--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to