[TYPO3-mvc] Cloning Model and add to repository
Jochen Rau
jochen.rau at typoplanet.de
Tue Jun 15 11:26:19 CEST 2010
Hi.
On 2010-06-14, Martin Kutschker <masi-no at spam-typo3.org> wrote:
> Sebastian Kurfürst schrieb:
>>> But that's what he tried to do. He cloned an old object to get a new one. He already assumed that it
>>> had no connection to the repositry, so he added it. That's where Extbase choked. Either a bug or he
>>> did something else and the error message wasn't helpful enough.
>>
>> The problem is that the object still needs the repository metadata
>> (read: the "original" UID) inside, as we need it if somebody does
>> $myRepository->update($object), which is the most common use-case.
>
> If I clone an object I would assume that any update of it will result an INSERT in the DB (along
> with INSERTs for all relations!). As "clone" is just a special case of "new" I don't understand why
> you would need the "original" UID. Actually I wouldn't mind if update() on a new or cloned object
> would trigger an error or raise an exception.
I agree with Masi here. cloning an object should result in a new object with the same property values and a different identity. In v4 this is the table-uid combination and the uid remains unset until the object has been written to the database.
regards
Jochen
More information about the TYPO3-project-typo3v4mvc
mailing list