Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 2.0.4
-
Fix Version/s: None
-
Component/s: None
-
Security Level: All
-
Labels:None
Description
The error message you get when an entity is missing an ID when attempting to persist it is rather confusing.
"Entity of type Some\Entity\Name is missing an assigned ID."
This does not tell me anything at all. I had absolutely no idea what an assigned ID was. I totally randomly noticed that I had mistyped @GeneratedValue as @GenratedValue, and fixing it fixed the issue.
Perhaps the message makes sense if you're familiar with Doctrine 2 internals, but I think it should be changed to something more helpful, such as "Entity of type X is missing primary key".
Alternatively it could keep the same message, but it could suggest a possible error ("Does the entity have a primary key set?") or perhaps the documentation could include a reference to it to help debug.
I too came across the same issue. The error message is not up to the mark here. In my case, mapping for primary key was missing the generator strategy,
<generator strategy="IDENTITY"/>
Thanks Jani Hartikainen for the hint.