Re: Inserting into an embedded list [SOLVED]

955 views
Skip to first unread message

Michael Campbell

unread,
Oct 29, 2013, 3:01:43 PM10/29/13
to orient-...@googlegroups.com
What I had to do was find the object, get its list of embedded items,
add my new thing to the list, then update the object with the entire
new list.


On Tue, Oct 29, 2013 at 9:53 AM, Michael Campbell
<michael....@gmail.com> wrote:
> I have a list of items in my class, and the items in this list are
> themselves multi layer.
>
> I'm having a hard time figuring out the syntax to add a new item to the list.
>
> My class is "searchJobs", and the list of items is
> "searchJobTaskContexts". My first attempt at an update to add a
> "context" to this embedded list is this, with the associated error
> (this is using the console.sh):
>
> update searchJobs add searchJobTaskContexts = {"runState": "FOO",
> "contextData": {"newKey" : "newValue", "newList": ["a", "b", "c"]}}
> where @RID = '#9:0'
>
> Error: com.orientechnologies.orient.core.exception.OCommandExecutionException:
> Error on execution of command: sql.select from searchJobs WHERE @RID
> = '#9:0'
>
> Error: java.lang.ClassCastException: java.util.HashMap cannot be cast
> to com.orientechnologies.orient.core.db.record.OIdentifiable
>
>
> There is no schema nor any properties.
>
> 1.5.1.

Luca Molino

unread,
Oct 30, 2013, 6:14:58 AM10/30/13
to orient-database
Hi Michael,

you need to add a field "@type" to tell orient the difference between a Map and a ODocument:

update searchJobs add searchJobTaskContexts = {"@type": "d", "runState": "FOO", "contextData": {"newKey" : "newValue", "newList": ["a", "b", "c"]}} where @RID = '#9:0'


2013/10/29 Michael Campbell <michael....@gmail.com>

--

---
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.
For more options, visit https://groups.google.com/groups/opt_out.



--
Luca Molino

Michael Campbell

unread,
Oct 30, 2013, 8:03:28 AM10/30/13
to orient-...@googlegroups.com
Thanks Luca, that works from console.sh, but the equivalent Java code
did not. (I'm new to Orient, so I could have screwed that up somehow,
but I am pretty sure I did try it.)

Наталь Капля

unread,
Feb 24, 2015, 10:59:09 PM2/24/15
to
Hi, Luca! What if I'm making chat, and I dont want for every message had overhead by: ""@type": "document", "@version": 0, "@fieldTypes": "Time=l"". Messages are not intended to change. I Could add into the list before this way: 
update XXX add msg = {"":{"Text":"text here", "ID":1}}
and everything was perfect.
I have skipped few updates and now on version 2.0.3 it doesn't work.

Thanks!
 
среда, 30 октября 2013 г., 13:14:58 UTC+3 пользователь Luca Molino написал:
Hi Michael,

you need to add a field "@type" to tell orient the difference between a Map and a ODocument:

update searchJobs add searchJobTaskContexts = {"@type": "d", "runState": "FOO", "contextData": {"newKey" : "newValue", "newList": ["a", "b", "c"]}} where @RID = '#9:0'

--
Luca Molino
Reply all
Reply to author
Forward
0 new messages