Jira issue originally created by user felicitus:
In my previous Bug Report DDC-871 I'm using a separate table for versioning copies. However, if one wishes to keep all versions in a single table, this causes some headaches, since the field with @version can't be set by the developer (i.e. Doctrine2 does magic here).
I'll try to describe it with some meta code.
Let's say you have the class SingleTable, which has a property version marked with @version and @id, and also a property id marked with @id. I know this isn't the preferred way since it's a composite primary key, but in theory it would work. I'm managing the ID of the object myself, which works without a problem.
The problem is that once a field is marked with @version, it isn't set during an insert operation. Doctrine2 relies on the field's default value. This causes the following problems:
No matter if there will be a change to the @version behavior or not, it should be documented a bit better in the documentation. Once I know if it will be changed or not, I can contribute additional documentation for this.
Comment created by @beberlei:
Yes @Version and @Id are not allowed. This should just throw an exception.
Comment created by felicitus:
As I'm already working on some documentation things, I will add this to the documentation and maybe also add some code to throw an Exception.
Just created a pull request for this (I added the bugfix + testcase), feel free to close after pull.
Implemented exception on this wrong usage.
Issue was closed with resolution "Fixed"