Any progress on the time-based history implementation? It seems like some years have passed since this discussion started and I wonder what are the recommended ways on achieving this with OrientDB?
Am Donnerstag, 23. Mai 2013 03:44:00 UTC+7 schrieb Lvc@: > > Hi Shaohua, > this isn't supported out of the box, but I don't know if any user did it. > > Lvc@ > > > On 22 May 2013 19:07, Shaohua Ma <mas...@gmail.com <javascript:>> wrote: > >> Hi, >> >> I am new to the OrientDB. But the history concept is really cool. Is it >> working yet? thanks. >> >> Shaohua >> >> >> On Wednesday, July 11, 2012 3:16:11 AM UTC-7, Thomas wrote: >>> >>> Hi, >>> >>> Using orientdb-graphed-1.0.1-SNAPSHOT I'm trying to create a history >>> solution using Hooks. >>> >>> From inside the hooks (ONLY onRecordBeforeUpdate and >>> onRecordBeforeDelete) I want to do the >>> following which work except for the final save operation :-( >>> >>> 1. Copy a document that is about to be saved or deleted. The copy will >>> be used to create a history document. >>> 2. Get all dirty fields from the document that is about to be updated >>> and then >>> 3. Copy the original values from the ODocument (if any exist) and >>> finally >>> 4. save the document to a History cluster. >>> >>> @Override >>> public boolean onRecordBeforeUpdate(ORecord<?> iRecord) { >>> if( iRecord instanceof ODocument ){ >>> ODocument doc = (ODocument) iRecord; >>> if(validateClusterId(doc)) { >>> ODocument copy = doc.copy(); // Contains dirty fields >>> that we need to update with the old values before we can save the document >>> to History. >>> String[] dirtyFields = doc.getDirtyFields(); >>> for(int i=0;i<dirtyFields.length;i++){ >>> if(doc.getOriginalValue(dirtyFields[i]) == null) >>> System.out.println("Field [ " + dirtyFields[i] + " ] did not exist in >>> previous version"); >>> else { >>> System.out.println("Original Value of dirty >>> field [ " + dirtyFields[i] + >>> " ] will be copied to History version. >>> Original value to be copied to the History version is [ " + >>> doc.getOriginalValue(dirtyFields[i]) + >>> " ] New value is [ " + doc.field(dirtyFields[i]) + " ]"); >>> copy.field(dirtyFields[i], doc.getOriginalValue( >>> dirtyFields[i])); >>> } >>> } >>> copy.save("History"); >>> } >>> } >>> return true; >>> } >>> >>> >>> The problem is the final save operation which give the following >>> exception: >>> >>> com.orientechnologies.orient.core.exception. >>> OConcurrentModificationException: >>> Cannot update record #8:0 in storage 'orientdb' because the version is >>> not the latest. >>> Probably you are updating an old record or it has been modified by >>> another user (db=v1 your=v0) >>> >>> I have also tried to use doc.getDatabase() and then create a new Vertex >>> or Edge, but this is not possible. >>> >>> >>> Any suggestions on how to save from inside the Hook? >>> >>> >>> Thanks >>> >>> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to orient-databa...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.