Objectify Ofy() is not finding the "query" method - objectify

I am new to objectify, and reading a tutorial on how to query. For some reason when I type the following code:
Query q = ofy().query(UserChoice.class).filter("email", email);
My Eclipse gives me a error saying "The method query(Class) is undefined for the type Objectify"
I'm not sure what this means? I imported Objectify correctly by using the following:
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
ObjectifyService.register(UserChoice.class);

Objective doesn't have an actual query method. In their API you can see all the calls you can make on the Objectify object, query() isn't one of those.
It looks like there may be an older version of Objectify that has a query method. The newest one (Build version: 4.0a3) doesn't have it, but an older version (Build version: 2.2.1) does. It looks like the class paths are the same, com.googlecode.objectify.Objectify. Make sure to load in the correct one or you are using the proper version with the `query() call.
The ObjectifyService you are using looks to be in the older version (2.2.1).

Related

CosmosDB - Entity Framework Core - Contains could not be translated

I try to manipulate a CosmosDB (SQL) using entity framework core 3.0 (Microsoft.EntityFrameworkCore.Cosmos 3.0.0).
Everything works fine except when I try to use Contains, StartWith, …
For example:
var query = _context.Challenges.Where(c => c.Name.Contains( "string"));
EF is supposed to translate it to the following SQL (that works perfectly on the CosmosDB – Query Explorer)
SELECT * FROM c WHERE CONTAINS(c.Name, "string")
But I receive the following error message:
The LINQ expression 'Where<Challenge>(\n source: DbSet<Challenge>, \n predicate: (c) => c.Name.Contains(\"string\"))' could not be translated.
Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync().
See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Of course, I don’t want to code it like the following, that will execute the entire contains on the client, just to make a simple LIKE…
List<Challenge> entities = _context.Challenges.AsEnumerable().Where(c => c.Name.Contains( "string")).ToList();
Anyone has an idea of to evaluate the "contains" on the server side ?
Note: I try the exact same code using UseSqlServer rather than UseCosmos (and by adding the needed [Key] annotation and creating a SQL server) and it works like a charm.... So it's a definitively a CosmosDB vs EF issue.
By posting the same issue on entity framework core forum (https://github.com/aspnet/EntityFrameworkCore/), the answer was that this feature is not yet implemented:
https://github.com/aspnet/EntityFrameworkCore/issues/18673
https://github.com/aspnet/EntityFrameworkCore/issues/16143
https://github.com/aspnet/EntityFrameworkCore/issues/18451
https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/6333414-implement-like-keyword

Firebase firestore,auth,storage Version error

I am using using firestore,auth and storage. I know all the versions of them should be same.
before:
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
this works fine
but now I have to use
documentReference2.update("test", FieldValue.arrayUnion(documentReference));
So I need to use the newer version of firestore. I tried changing it to 19.0.0,18.0.0,16 etc for all of them. I tried every possible way. But always gives the
error:Failed to resolve: com.google.firebase:firebase-auth:16.0.0
base:firebase-storage:16.0.0 Show in File Show in Project Structure
dialog
I'm unable to find a solution
Update the following:
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
into this:
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'com.google.firebase:firebase-storage:17.0.0'
Check the latest versions here:
https://firebase.google.com/support/release-notes/android#latest_sdk_versions

Marklogic Rest API for directory-query

I have the following XQuery which I use to fetch documents for a directory.
xquery version "1.0-ml";
cts:search(fn:collection(), cts:directory-query("/Path/To/Docs/", "infinity"))
Now I need to translate this into a REST call but I can't seem to crack it following the documentation on this page.
https://docs.marklogic.com/REST/GET/v1/search
Update:
using the Jersey REST API, It tried this but got 406 Error
String query = "{\"queries\":[ {\"directory-query\":{\"uri\":[\"/Path/to/Docs/\"]},\"infinite\":true} ]}";
String encodedQuery = URLEncoder.encode(query, "UTF-8");
WebTarget target = searchWebTarget.queryParam("structuredQuery", encodedQuery);
final Response response = target.request().get();
Any ideas?
As David said, you don't need to use structured query for this purpose, but in case you have future need:
I believe your original issue was that this is not a well-formed structured query:
{\"queries\":[ {\"directory-query\":{\"uri\":[\"/Path/to/Docs/\"]},\"infinite\":true} ]}
You're missing the top level "query" property. You can find an example of a fully formed structured query that uses directory-query here:
http://docs.marklogic.com/guide/search-dev/structured-query#id_97452
Also, you're probably already aware, but there is a native Java API that sits atop the REST API. You can learn more about this API here:
https://docs.marklogic.com/javadoc/client/index.html
http://docs.marklogic.com/guide/java
Constraining by directory is a query parameter directly on the search API. NO other notation needed.
See the docs here: https://docs.marklogic.com/REST/GET/v1/search

Can't access PFObject as dictionary

I am starting to use Parse and in the documentation it has examples to use the PFObject as an NSDitionary like this:
// Create the post
PFObject *myPost = [PFObject objectWithClassName:#"Post"];
myPost[#"title"] = #"I'm Hungry";
but i am getting a compiler error:
"Expected method to write dictionary element not found on object of type "PFObject"
But if I access the myPost PFObject like this, it works:
[myPost setObject:#"I'm Hungry" forKey:#"title"];
What is the problem?
I though that PFObject could be accesses as a dictionary?
thanks
I would check that you are using the latest version of the Parse SDK. This is new functionality and my guess is you haven't downloaded the SDK since this feature was introduced.
when i try your code at my side it gives me success message. I think you are using old parse library.
Thanks.
Downloading latest XCode should help. Subscript syntax is available from Xcode 4.4+

Error while compiling botan sample example in Qt

I am trying to find out the error for two days but still haven't got this unknown reason figure out.
I have configured and compiled Botan library. Everything goes ok but when try to write this sample code to be run..
S2K* s2k = get_s2k("PBKDF2(SHA-256)");
s2k->set_iterations(4049);
SecureVector<byte> key_and_IV = s2k->derive_key(48, passphrase).bits_of();
SymmetricKey key(key_and_IV, 32);
it says error: 'class Botan::PBKDF' has no member named 'set_iterations'
How can I solve this problem ?
The Botan docs for v1.11.1 report that the function get_s2k() has been deprecated, recommending that you use get_pbkdf() instead.
According to the docs, get_sdk(algospec) just returns the result of a call to get_pbkdf(algo_spec) which will give you a pointer to an instance of the class Botan::PBKDF.
First things first then, your code needs to be something more like:
PBKDF *s2k = getpbkdf("PBKDF2(SHA-256)");
Unfortunately without knowing what you want to do with s2k I can't help any further, as the docs have no reference to a public member function of PBKDF called set_iterations(). You're getting the error you mention because Botan::PBKDF really does have no member named set_iterations. You need to read the docs, work out what the purpose of set_iterations() was in your now deprecated example and hence how to achieve that purpose in the newer version of the library.
Possibly you missed your library header... as your error message says: 'has no member named...'

Resources