Hi, this seems to be a bug, could you please open an issue here
https://github.com/orientechnologies/orientdb/issues/ Thanks Luigi 2016-10-04 6:58 GMT+02:00 <[email protected]>: > Hi guys, > > I hope I'm doing something wrong and it's not a shortcoming for the > orientdb's functionality. I'm working on the application, which will need > to store different objects of complex structure (objects inside of > objects). For example, Person object may have Address object, Contacts, and > may need to link to some other objects, etc. Sometimes these objects may go > few levels deep. I created the class with an embedded class and it all > works good when I run query in the console. I have to use these extra > fields ("@type":"d", "@class":"Address") in the embedded object in order > for the query to understand the embedded object. > > Here is example of a working query: > insert into Account (company, website, address) values ('Seller 0', ' > http://www.seller0.com', {"@type":"d", "@class":"Address", "street":"1234 > Sunset Dr.", "city":"Santa Monica", "state":"CA", "zip":"90046"}) > > The problem I"m running into, is that I will need to do this functionality > dynamically in Java and I have modeled my java classes to be exact as the > classes in the database, which makes sense to me and would save a lot of > time. However, when I serialize my Java object into JSON and create > ODocument object from this JSON, on save() the database is not taking it. > Here is example of one simple serialized java object: > json = > { > "account": "#25:0", > "meta": { > "created": "2016-10-03T21:10:21.77-07:00", > "ip": "0:0:0:0:0:0:0:1", > "contentType": "application/x-www-form-urlencoded", > "userAgent": "PostmanRuntime/2.5.2" > }, > "data": "firstName=Jessica&lastName=Smith" > } > > When I use this logic it fails: > *ODocument d = new ODocument("RawLead").fromJSON(json);* > *d.save(); * > > I get Java error: Error: Error during saving of record with rid #-1:-1 > > For the above JSON I have the following "RawLead" class with embedded > "LeadMetadata" class: > > > CLASS 'RawLead' > > PROPERTIES > > +----+-------+--------+-----------------+---------+--------+ > --------+----+----+-------+-------+ > > |# |NAME |TYPE |LINKED-TYPE/CLASS|MANDATORY|READONLY|NOT-NULL|MIN > |MAX |COLLATE|DEFAULT| > > +----+-------+--------+-----------------+---------+--------+ > --------+----+----+-------+-------+ > > |0 |data |STRING | |true |false |true | > | |default| | > > |1 |meta |EMBEDDED|LeadMetadata |true |false |true | > | |default| | > > |2 |account|LINK |Account |true |false |true | > | |default| | > > +----+-------+--------+-----------------+---------+--------+ > --------+----+----+-------+-------+ > > CLASS 'LeadMetadata' > > PROPERTIES > > +----+-----------+--------+-----------------+---------+----- > ---+--------+----+----+-------+---------+ > > |# |NAME |TYPE |LINKED-TYPE/CLASS|MANDATORY|READONLY|NOT-NULL|MIN > |MAX |COLLATE|DEFAULT | > > +----+-----------+--------+-----------------+---------+----- > ---+--------+----+----+-------+---------+ > > |0 |created |DATETIME| |false |true |false | > | |default|sysdate()| > > |1 |ip |STRING | |true |false |true |7 > |40 |default| | > > |2 |userAgent |STRING | |true |false |true |1 > |100 |default| | > > |3 |contentType|STRING | |true |false |true |4 > |50 |default| | > > +----+-----------+--------+-----------------+---------+----- > ---+--------+----+----+-------+---------+ > > I assume it's because I don't have the magic fields ("@type":"d", > "@class":"Meta") in my JSON. If this is correct, I need an advise on how to > go around it or maybe there is a different and more straight forward way of > doing it? I was hopping that I can simply serialize my exact Java objects > into JSON format then create ODocument and simply save it in the database. > That would be so awesome. Please help. > > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- --- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
