Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/03/2013, 09:52
wilmer30
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 3 meses
Puntos: 12
Asociaciones en doctrine 2

Hola:

El concepto dice: una relacion bidireccional tiene un lado propietario y otro inverso en cambio el unidireccional solo tiene un lado propietario. Entonces el lado propietario determina las modificaciones de la relacion en la base de datos.

yo tengo la siguiente tabla departamento

Cita:
+--------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+----------------+
| id | int(4) | NO | PRI | NULL | auto_increment |
| descripcion | varchar(200) | YES | | NULL | |
| departamento_id | int(4) | YES | | NULL | |
donde el lado propietario sería id y el inverso departamento_id las relaciones serían OneToMany bidireccional por lo que generé este modelo para representarlo:

Código PHP:
Ver original
  1. class Departamento
  2. {
  3.     /**
  4.      * @var integer
  5.      * @OneToMany(targetEntity="departamento", inversedBy="departamento_id")
  6.      * @JoinColumn(name="id", referencedColumnName="departamento_id")
  7.      *
  8.      * @Column(name="id", type="integer", nullable=false)
  9.      * @Id
  10.      * @GeneratedValue(strategy="IDENTITY")
  11.      */
  12.     private $id;
  13.     /**
  14.      * @var string
  15.      *
  16.      * @Column(name="descripcion", type="string", length=200, nullable=false)
  17.      */
  18.     private $descripcion;
  19.     /**
  20.      * @var integer
  21.      * @ManyToOne(targetEntity="departamento",mappedBy="id")
  22.      * @Column(name="departamento_id", type="integer", nullable=false)
  23.      */
  24.     private $departamentoId;
  25. ....
, tengo un mensaje de Creation Error en doctrine

Cita:
[Creation Error] The annotation @OneToMany declared on property Entities\Departamento::$id does not have a property named "inversedB
y". Available properties: mappedBy, targetEntity, cascade, fetch, orphanRemoval, indexBy