Doctrine problem vazby oneToMany – manyToOne
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- nyccoss
- Člen | 18
Ahoj. Uz nekolik dnu se trapim proc mi nejde vazba oneToMany – manyToOne mezi dvemi entitami
pouzivam definici Doctrine entit v YAMLu
mam 2 entity
Core\Module:
type: entity
table: module
options:
collate: utf8_czech_ci
id:
id:
type: integer
generator:
strategy: AUTO
fields:
name:
nullable: false
type: string
length: 250
label:
nullable: false
type: string
length: 250
position:
nullable: true
type: integer
oneToMany:
actions:
targetEntity: Core\ModuleAction
mappedBy: module
a
Core\ModuleAction:
type: entity
table: module_action
options:
collate: utf8_czech_ci
id:
id:
type: integer
generator:
strategy: AUTO
fields:
name:
nullable: false
type: string
length: 250
label:
nullable: false
type: string
length: 250
callback:
nullable: true
type: string
length: 250
manyToOne:
module:
targetEntity: Core\Module
inversedBy: actions
oneToMany:
roles:
targetEntity: Core\RoleModuleAction
mappedBy: moduleAction
Podle me je vse spravne, ale pres to konzole hlasi
php index.php orm:generate-entities ../app/model/Core/
Fatal error: Call to a member function setValue() on null in /var/www/html/mineboard/app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 2773
ErrorException: Call to a member function setValue() on null in /var/www/html/mineboard/app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:2773
Stack trace:
#0 [internal function]: Tracy\Debugger::shutdownHandler()
#1 {main}
pokud dam pryc sekci oneToMany z entity Core\Module, vsechno bezi (ale samozrejme ta kolekce tam chybi)…
Nejaky napad kde je chyba?
pouzivam Nette 2.4
vzhledem k nekompatibilite Kdyby\Doctrine s Nette 2.4 jsem dohledal zde v diskuzich jak to uchodit, takze muj composer.json vypada takto:
"require": {
"php": ">=5.6.0",
"nette/application": "^2.4.4",
"nette/bootstrap": "^2.4.3",
"nette/caching": "^2.5",
"nette/database": "^2.4",
"nette/di": "^2.4",
"nette/finder": "^2.4",
"nette/forms": "^2.4",
"nette/http": "^2.4",
"nette/mail": "^2.4",
"nette/robot-loader": "^2.4 || ^3.0",
"nette/safe-stream": "^2.3",
"nette/security": "^2.4",
"nette/utils": "^2.4",
"latte/latte": "^2.4",
"tracy/tracy": "^2.4",
"kdyby/doctrine": "dev-master",
"kdyby/doctrine-cache": "dev-master",
"kdyby/doctrine-dbal-batchimport": "dev-master",
"atreo/migrations": "~1.0",
"kdyby/fake-session": "^2.0",
"kdyby/events": "^3.1"
}
Dekuji za jakoukoli radu. Uz nejak nevim kde by mohla byt chyba.
PS: stejny problem jsem mel, kdyz jsem se snazil uchodit vazmu M:N. Nic mene, tu jsem obesel pomoci dvou oneToMany rucne. A tam mi funguji oba dva smery. Jak kolekce, tak prima vazba.