// saves doc again after changing the title (which indeed stores a new version of it)
doc.setTitle ( newTitle );
DocCatalog.save( doc );
// gets a number indicating how many versions of the document exist
i_versions = DocCatalog.getVersions( docid );
// returns second-last version of the document
doc = DocCatalog.get( docid, i_versions-1 );
Wouldn't something like a custom DataMapper work?
doc = DocCatalog.get( docid, version );
Assuming you can consider each object a materialization of what the object represents, at a given moment (in time). Instead of being an object with a "version" property, the "versioning" is taken care of by the datamapper/catalog/database; ie, the object doesn't know about versions, but the object storage system does.
Saving/storing an object in the datamapper would generate a new version:
// saves doc again after changing the title (which indeed stores a new version of it)
doc.setTitle ( newTitle );
DocCatalog.save( doc );
// gets a number indicating how many versions of the document exist
i_versions = DocCatalog.getVersions( docid );
// returns second-last version of the document
doc = DocCatalog.get( docid, i_versions-1 );
发布评论
评论(1)
像自定义 DataMapper 这样的东西不起作用吗?
假设您可以将每个对象视为该对象在给定时刻(及时)所代表的内容的具体化。 “版本控制”不是由具有“版本”属性的对象,而是由数据映射器/目录/数据库负责;即,对象不知道版本,但对象存储系统知道。
在数据映射器中保存/存储对象将生成一个新版本:
Wouldn't something like a custom DataMapper work?
Assuming you can consider each object a materialization of what the object represents, at a given moment (in time). Instead of being an object with a "version" property, the "versioning" is taken care of by the datamapper/catalog/database; ie, the object doesn't know about versions, but the object storage system does.
Saving/storing an object in the datamapper would generate a new version: