Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.0-ALPHA3
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
When cascading 'persist' operations, the object which was not persisted implicitly is being written to the DB with wrong parameters, broken SQL:
INSERT INTO email (email, userId) VALUES (?, ?)
array(3) {
[1]=>
NULL
[2]=>
string(16) "user@example.com"
[3]=>
int(1)
}
See the attached example for details... When I uncomment the "$em->persist($email);" line, everything works as expected (but I'd like this persist to be done automatically...)
Indeed this looks like a bug, but it is unrelated to cascades.
I will explain on your code sample:
Just to clarify. So this is a bug in the "persistence by reachability".
"persistence by reachability" means that a NEW entity (like $email) that is associated to a MANAGED entity (like $user) and the association has cascade=persist is automatically persisted on flush().
I still need to write about persistence by reachability in the manual but as you have already found out, it is intuitive since you expect that to happen.