Each entity in the schema that I am going to show you is defined in this way: [ENTITY]. Every entity is identified with ".idName". Several fields like ".idName1.IdName2" create a compound key, where at least one of them is a foreign key.
[Device.deviceId] has [Bookable.deviceId.bookableId]
(.deviceId is a identifies a device)
[Bookable.deviceId.bookableId] has [Booking.deviceId.bookableId.bookingId]
(the tuple .deviceId.bookableId identifies a Bookable)
I already achieved to create a oneToMany relation between [Device] and [Bookable] (see code) however when I want to make another oneToMany relation between Bookable and Booking it does not work and Doctrine gives me an error. After running:
php app/console doctrine:schema:update
Shows this error:
[Doctrine\ORM\ORMException]
Column name `deviceId` referenced for relation from SearchDevice\WebBundle\Entity\Booking towards SearchDev
ice\WebBundle\Entity\Bookable does not exist.
The full yaml code is the next one: Device.orm.yml file:
SearchDevice\WebBundle\Entity\Device:
type: entity
id:
deviceId:
type: integer
generator: {strategy: AUTO}
oneToMany:
bookables:
targetEntity: Bookable
mappedBy: device
Bookable file:
SearchDevice\WebBundle\Entity\Bookable:
type: entity
id:
deviceId:
associationKey: deviceId
bookableId:
type: integer
generator: {strategy: AUTO}
manyToOne:
device:
targetEntity: Device
inversedBy: bookables
joinColumns:
deviceId:
referencedColumnName: deviceId
oneToMany:
bookings:
targetEntity: Booking
mappedBy: bookable
Booking file:
SearchDevice\WebBundle\Entity\Booking:
type: entity
id:
deviceId:
associationKey: deviceId
bookableId:
associationKey: bookableId
bookingId:
type: integer
generator: {strategy: AUTO}
manyToOne:
bookable:
targetEntity: Bookable
inversedBy: bookings
joinColumns:
deviceId:
referencedColumnName: deviceId
bookableId:
referencedColumnName: bookableId
Looks like if the problem is in Booking entity, where I am saying that "deviceId" is a column of Bookable entity. Since it is a foreign key column and not an explicit column then Doctrine has problems doing this relationship.