I'm trying to figure out the purpose of vararg parameter in the above methods and can't figure out why.
For example, take the below method that allows binding zero or more String parameters:
public GqlQuery.Builder<V> addBinding(String... value)
Since there is no JavaDoc on these methods yet - one way to interpret this method is that it allows binding of a ListValue to do search on Array property. Other way is to bind each String value to @1, @2, etc. Looking at the code tells me that multiple values are converted to a ListValue, so...
However, when I try this with more than one value,
Query<Entity> query = Query.newGqlQueryBuilder(Query.ResultType.ENTITY, "select * from MyEntity where MyProperty= @1").addBinding("value1", "value2").build();
This errors out with the below exception:
Exception in thread "main" com.google.cloud.datastore.DatastoreException: A list value is not allowed
at com.google.cloud.datastore.spi.DefaultDatastoreRpc.translate(DefaultDatastoreRpc.java:110)
at com.google.cloud.datastore.spi.DefaultDatastoreRpc.translate(DefaultDatastoreRpc.java:96)
at com.google.cloud.datastore.spi.DefaultDatastoreRpc.runQuery(DefaultDatastoreRpc.java:164)
at com.google.cloud.datastore.DatastoreImpl$1.call(DatastoreImpl.java:93)
at com.google.cloud.datastore.DatastoreImpl$1.call(DatastoreImpl.java:89)
at com.google.cloud.RetryHelper.doRetry(RetryHelper.java:179)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:244)
at com.google.cloud.datastore.DatastoreImpl.runQuery(DatastoreImpl.java:88)
at com.google.cloud.datastore.QueryResultsImpl.sendRequest(QueryResultsImpl.java:73)
at com.google.cloud.datastore.QueryResultsImpl.<init>(QueryResultsImpl.java:57)
at com.google.cloud.datastore.DatastoreImpl.run(DatastoreImpl.java:82)
at com.google.cloud.datastore.DatastoreImpl.run(DatastoreImpl.java:73)
So, why do these methods have varargs?
I'm trying to figure out the purpose of vararg parameter in the above methods and can't figure out why.
For example, take the below method that allows binding zero or more String parameters:
public GqlQuery.Builder<V> addBinding(String... value)Since there is no JavaDoc on these methods yet - one way to interpret this method is that it allows binding of a
ListValueto do search on Array property. Other way is to bind each String value to @1, @2, etc. Looking at the code tells me that multiple values are converted to a ListValue, so...However, when I try this with more than one value,
Query<Entity> query = Query.newGqlQueryBuilder(Query.ResultType.ENTITY, "select * from MyEntity where MyProperty= @1").addBinding("value1", "value2").build();This errors out with the below exception:
So, why do these methods have varargs?