Discussion:
[orientdb] OrientDB3.0.2 create embeddedList via console or Java results into incompatible type
Paarek
2018-07-10 23:22:53 UTC
Permalink
Hi! I am using OrientDB3.0.2 and need to use embeddedList (or embeddedSet)

I tried following but does not work, not sure why. Any help is much
appreciated.

--------------
Schema:
create class Phone EXTENDS V
create property Phone.number String

create class Profile EXTENDS V
create property Profile.name String
create property Profile.phone embeddedList Phone

--------------
CREATE VERTEX Profile CONTENT { "name" : "John", "phone" : {"@type":"d",
"number" : "212" }}
CREATE VERTEX Profile SET name = "John", phone = { "@type":"d", "number" :
"212" }
INSERT INTO Profile (name, phone) VALUES ("John", { "@type": "d", "number":
"212", "@version": 0 })

Results In:

Error: com.orientechnologies.orient.core.exception.OValidationException:
The field 'Profile.phone' has been declared as EMBEDDEDLIST but an
incompatible type is used. Value: 212



-- But following Works because profile has no address property --

INSERT INTO Profile (name, address) VALUES ('John', { "@type": "d",
"number": "212", "@version": 0 })

--------------

I tried the same with Java but also getting exception as follows:


com.orientechnologies.orient.core.exception.OValidationException: The field
'Profile.phone' has been declared as EMBEDDEDLIST but an incompatible type
is used.
at
com.orientechnologies.orient.core.record.impl.ODocument.validateEmbedded(ODocument.java:814)
at
com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:601)
at
com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2364)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.saveInternal(ODatabaseDocumentAbstract.java:2039)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:2019)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:84)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2108)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2099)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:63)
at
com.sqad.repository.OrientDBOperationsImpl.updateVertexProperty(OrientDBOperationsImpl.java:330)
--
---
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Luigi Dell'Aquila
2018-07-11 06:31:55 UTC
Permalink
Hi,

When you have an embedded list property, you have to pass a list to make it
work. You are passing a single document now.
Please try the following:

CREATE VERTEX Profile SET name = "John", phone = [{ "@type":"d", "number" :
"212" }]

Thanks

Luigi
Post by Paarek
Hi! I am using OrientDB3.0.2 and need to use embeddedList (or embeddedSet)
I tried following but does not work, not sure why. Any help is much
appreciated.
--------------
create class Phone EXTENDS V
create property Phone.number String
create class Profile EXTENDS V
create property Profile.name String
create property Profile.phone embeddedList Phone
--------------
"number" : "212" }}
"212" }
The field 'Profile.phone' has been declared as EMBEDDEDLIST but an
incompatible type is used. Value: 212
-- But following Works because profile has no address property --
--------------
com.orientechnologies.orient.core.exception.OValidationException: The
field 'Profile.phone' has been declared as EMBEDDEDLIST but an incompatible
type is used.
at
com.orientechnologies.orient.core.record.impl.ODocument.validateEmbedded(ODocument.java:814)
at
com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:601)
at
com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2364)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.saveInternal(ODatabaseDocumentAbstract.java:2039)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:2019)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:84)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2108)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2099)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:63)
at
com.sqad.repository.OrientDBOperationsImpl.updateVertexProperty(OrientDBOperationsImpl.java:330)
--
---
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
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 orient-database+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
d***@gmail.com
2018-10-07 21:34:08 UTC
Permalink
When executing a query just like the one below, but on a Document class
rather than a vertex class, using the JSON list bracket notation results in
the following error:

*orientdb {db=foo}> insert into inspection_reports set extension="pdf",
filehash="somehash", notes=[{"@type":"d", "content":"some content",
"date":"datestring"}]*
*Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException:
Error parsing query:*
*insert into inspection_reports set extension="pdf", filehash="somehash",
notes=[{"@class":"note", "@type":"d", "content":"some content",
"date":"datestring"}*

*Encountered " "[" "[ "" at line 1, column 80.*

This is from the console while attached to remote:localhost. *notes *is an *embeddedlist
*type within *inspection_reports*

I've tried more than a few permutations of @class, @type, with brackets,
without brackets. Any got any pointers?
Post by Luigi Dell'Aquila
Hi,
When you have an embedded list property, you have to pass a list to make
it work. You are passing a single document now.
: "212" }]
Thanks
Luigi
Post by Paarek
Hi! I am using OrientDB3.0.2 and need to use embeddedList (or embeddedSet)
I tried following but does not work, not sure why. Any help is much
appreciated.
--------------
create class Phone EXTENDS V
create property Phone.number String
create class Profile EXTENDS V
create property Profile.name String
create property Profile.phone embeddedList Phone
--------------
"number" : "212" }}
: "212" }
The field 'Profile.phone' has been declared as EMBEDDEDLIST but an
incompatible type is used. Value: 212
-- But following Works because profile has no address property --
--------------
com.orientechnologies.orient.core.exception.OValidationException: The
field 'Profile.phone' has been declared as EMBEDDEDLIST but an incompatible
type is used.
at
com.orientechnologies.orient.core.record.impl.ODocument.validateEmbedded(ODocument.java:814)
at
com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:601)
at
com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2364)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.saveInternal(ODatabaseDocumentAbstract.java:2039)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:2019)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:84)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2108)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2099)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:63)
at
com.sqad.repository.OrientDBOperationsImpl.updateVertexProperty(OrientDBOperationsImpl.java:330)
--
---
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
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 orient-database+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Luigi Dell'Aquila
2018-10-08 08:05:32 UTC
Permalink
Hi David,

Is it in latest 3.0.8? I tried the query in Studio and it seems to work fine

Thanks

Luigi
Post by d***@gmail.com
When executing a query just like the one below, but on a Document class
rather than a vertex class, using the JSON list bracket notation results in
*orientdb {db=foo}> insert into inspection_reports set extension="pdf",
"date":"datestring"}]*
Error parsing query:*
*insert into inspection_reports set extension="pdf", filehash="somehash",
"date":"datestring"}*
*Encountered " "[" "[ "" at line 1, column 80.*
This is from the console while attached to remote:localhost. *notes *is
an *embeddedlist *type within *inspection_reports*
without brackets. Any got any pointers?
Post by Luigi Dell'Aquila
Hi,
When you have an embedded list property, you have to pass a list to make
it work. You are passing a single document now.
: "212" }]
Thanks
Luigi
Post by Paarek
Hi! I am using OrientDB3.0.2 and need to use embeddedList
(or embeddedSet)
I tried following but does not work, not sure why. Any help is much
appreciated.
--------------
create class Phone EXTENDS V
create property Phone.number String
create class Profile EXTENDS V
create property Profile.name String
create property Profile.phone embeddedList Phone
--------------
"number" : "212" }}
: "212" }
The field 'Profile.phone' has been declared as EMBEDDEDLIST but an
incompatible type is used. Value: 212
-- But following Works because profile has no address property --
--------------
com.orientechnologies.orient.core.exception.OValidationException: The
field 'Profile.phone' has been declared as EMBEDDEDLIST but an incompatible
type is used.
at
com.orientechnologies.orient.core.record.impl.ODocument.validateEmbedded(ODocument.java:814)
at
com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:601)
at
com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2364)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.saveInternal(ODatabaseDocumentAbstract.java:2039)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:2019)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:84)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2108)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2099)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:63)
at
com.sqad.repository.OrientDBOperationsImpl.updateVertexProperty(OrientDBOperationsImpl.java:330)
--
---
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
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
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 orient-database+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
d***@gmail.com
2018-10-08 11:05:45 UTC
Permalink
Yes, it does work as expected in 3.0.8. 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-database+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Paarek
2018-07-11 13:03:47 UTC
Permalink
Luigi,

I appreciate the help.

Also, then can you help why following method does not work? I am able to
retrieve and convert the saved profile record to profile java class without
any problem (see code).
See attached file - ProfileTest.Java

public void updateVertexProperty(OVertex vertex, String propertyName,
List<Phone> propertyValues) {
vertex.setProperty(propertyName, propertyValues, OType.EMBEDDEDLIST);
vertex.save();
}


I am not able to find proper documentation of the solution you provided on
SQL or Java side at following location. Can you please point me to it?
https://orientdb.com/docs/last/sql/SQL-Create-Vertex.html

Should I just use one of the Tinkerpop Java? But again the documentation at
following locations seems very minimal and do not provide example of
EMBEDDEDLIST.
https://orientdb.com/docs/last/java/Java-Query-API.html
https://tinkerpop.apache.org/docs/current/reference/#connecting-via-java

So what are the recommended resources for creating Java / Tinkerpop based
solution using OrientDB.

Thanks
Post by Paarek
Hi! I am using OrientDB3.0.2 and need to use embeddedList (or embeddedSet)
I tried following but does not work, not sure why. Any help is much
appreciated.
--------------
create class Phone EXTENDS V
create property Phone.number String
create class Profile EXTENDS V
create property Profile.name String
create property Profile.phone embeddedList Phone
--------------
"number" : "212" }}
"212" }
The field 'Profile.phone' has been declared as EMBEDDEDLIST but an
incompatible type is used. Value: 212
-- But following Works because profile has no address property --
--------------
com.orientechnologies.orient.core.exception.OValidationException: The
field 'Profile.phone' has been declared as EMBEDDEDLIST but an incompatible
type is used.
at
com.orientechnologies.orient.core.record.impl.ODocument.validateEmbedded(ODocument.java:814)
at
com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:601)
at
com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2364)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.saveInternal(ODatabaseDocumentAbstract.java:2039)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:2019)
at
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:84)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2108)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2099)
at
com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:63)
at
com.sqad.repository.OrientDBOperationsImpl.updateVertexProperty(OrientDBOperationsImpl.java:330)
--
---
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...