Exception while updating a document with a Date field

19 views
Skip to first unread message

Roberto Franchini

unread,
May 26, 2011, 5:57:20 AM5/26/11
to orient-database
Hello,
afeter the update to the last 1.0rc2 and subsequent svn revision (now
3011) I've got a problem updating a Document which has a Date field.

Scenario:
- fetch documents from storage
- do some analysis
- store analysis documents
- "attach" analysis to original document:

//masterKey is an indexed field
String masterKey=....
ODocument master = findByPrimaryKey(masterKey);

ODocument analysis = new ODocument(db, "Analysis");
analysis.save();


Then we update references this way:

String query = "update master add analysis = #" +
analysis.getIdentity().toString() + " where masterKey = '" + masterKey
+ "'";
OCommandSQL commandSQL = new OCommandSQL(query);
db.command(commandSQL).execute();

com.orientechnologies.orient.core.exception.ODatabaseException: Error
on saving record in cluster #7
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeSaveRecord(ODatabaseRecordAbstract.java:506)
at com.orientechnologies.orient.core.tx.OTransactionNoTx.saveRecord(OTransactionNoTx.java:58)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.save(ODatabaseRecordTx.java:202)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.save(ODatabaseRecordTx.java:40)
at com.orientechnologies.orient.core.record.ORecordAbstract.save(ORecordAbstract.java:279)
at com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.save(ORecordSchemaAwareAbstract.java:64)
at com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.save(ORecordSchemaAwareAbstract.java:55)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLUpdate.result(OCommandExecutorSQLUpdate.java:243)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.processRecordAsResult(OCommandExecutorSQLSelect.java:555)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.addResult(OCommandExecutorSQLSelect.java:327)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.searchInClasses(OCommandExecutorSQLSelect.java:577)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:166)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:50)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:59)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:62)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:38)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.query(ODatabaseRecordAbstract.java:250)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLUpdate.execute(OCommandExecutorSQLUpdate.java:122)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:50)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:59)
at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:62)
at it.celi.persistence.repository.analysis.AnalysisOrientRepository.save(AnalysisOrientRepository.java:85)
at it.celi.persistence.repository.analysis.AnalysisOrientRepositoryTest.shouldSaveAnalysis(AnalysisOrientRepositoryTest.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException: java.util.Date cannot be cast
to java.lang.String
at java.lang.String.compareTo(String.java:109)
at com.orientechnologies.common.collection.OMVRBTree.getEntry(OMVRBTree.java:365)
at com.orientechnologies.common.collection.OMVRBTree.getEntry(OMVRBTree.java:307)
at com.orientechnologies.common.collection.OMVRBTree.get(OMVRBTree.java:244)
at com.orientechnologies.orient.core.index.OIndexMVRBTreeAbstract.get(OIndexMVRBTreeAbstract.java:188)
at com.orientechnologies.orient.core.index.OIndexNotUnique.remove(OIndexNotUnique.java:60)
at com.orientechnologies.orient.core.index.OPropertyIndexManager.onRecordAfterUpdate(OPropertyIndexManager.java:83)
at com.orientechnologies.orient.core.hook.ODocumentHookAbstract.onTrigger(ODocumentHookAbstract.java:78)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.callbackHooks(ODatabaseRecordAbstract.java:615)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeSaveRecord(ODatabaseRecordAbstract.java:491)
... 47 more

I try his way too (this way didn't work before, i think at leas 1.0rc1):

master.field("analysis", analysis, OType.LINK);
master.save();

com.orientechnologies.orient.core.exception.ODatabaseException: Error
on saving record in cluster #7
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeSaveRecord(ODatabaseRecordAbstract.java:506)
at com.orientechnologies.orient.core.tx.OTransactionNoTx.saveRecord(OTransactionNoTx.java:58)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.save(ODatabaseRecordTx.java:202)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.save(ODatabaseRecordTx.java:40)
at com.orientechnologies.orient.core.record.ORecordAbstract.save(ORecordAbstract.java:279)
at com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.save(ORecordSchemaAwareAbstract.java:64)
at com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.save(ORecordSchemaAwareAbstract.java:55)
at it.celi.persistence.repository.analysis.AnalysisOrientRepository.save(AnalysisOrientRepository.java:89)
at it.celi.persistence.repository.analysis.AnalysisOrientRepositoryTest.shouldSaveAnalysis(AnalysisOrientRepositoryTest.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException:
com.orientechnologies.orient.core.record.impl.ODocument cannot be cast
to java.util.Collection
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerCSVAbstract.fieldToStream(ORecordSerializerCSVAbstract.java:242)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV.toString(ORecordSerializerSchemaAware2CSV.java:241)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.toStream(ORecordSerializerStringAbstract.java:77)
at com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.toStream(ORecordSchemaAwareAbstract.java:134)
at com.orientechnologies.orient.core.record.ORecordSchemaAwareAbstract.toStream(ORecordSchemaAwareAbstract.java:129)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeSaveRecord(ODatabaseRecordAbstract.java:438)
... 33 more


I think the problem is in the Date field that is casted to String
maybe without formatting.
Let me know if I should open an issue.
Cheers,
FRANK

--
Roberto Franchini
http://www.celi.it
http://www.blogmeter.it
http://www.memesphere.it
Tel +39.011.562.71.15
jabber:ro.fra...@gmail.com skype:ro.franchini

Luca Garulli

unread,
May 26, 2011, 6:22:41 AM5/26/11
to orient-...@googlegroups.com
Hi Roberto,
Could you provide me a simple test case for it?

By the way don't put # because the toString() already dump the # character:

String query = "update master add analysis = " +

analysis.getIdentity().toString() + " where masterKey = '" + masterKey
+ "'";

Lvc@

Roberto Franchini

unread,
Jun 8, 2011, 9:57:14 AM6/8/11
to orient-...@googlegroups.com
On Thu, May 26, 2011 at 12:22 PM, Luca Garulli <l.ga...@gmail.com> wrote:
> Hi Roberto,
> Could you provide me a simple test case for it?
> By the way don't put # because the toString() already dump the # character:
> String query = "update master add analysis = " +
> analysis.getIdentity().toString() + " where masterKey = '" + masterKey
> + "'";

After the last update and some work all my tests are green now.
I switched to DATETIME my DATE field, but I don't know if this is the solution.

Cheers,
FRANK
--
Roberto Franchini
http://www.celi.it
http://www.blogmeter.it

Luca Garulli

unread,
Jun 8, 2011, 11:47:59 AM6/8/11
to orient-...@googlegroups.com
Not it's the only one type that supports date with precision major than the DAY. Some news is planned (see other threads about Date management) but are post-poned for the 1.1.

Lvc@
Reply all
Reply to author
Forward
0 new messages