Build Query object from query string

87 views
Skip to first unread message

Xybrek

unread,
Nov 2, 2012, 12:56:34 PM11/2/12
to objectify...@googlegroups.com

Is it possible to build a Query object with Objectify with a query string? I mean, I know Objectify builds queries like:

Query<Foo> q = ofy().load().type(Foo.class);
q = q.filter("bar", b);

However, is there a way or any plans for Objectify to have the ability to build Query objects from query string like:

String query = "SELECT * FROM Foo WHERE bar = b";
List<Foo> foo = ofy().buildQuery(query).asList();

Jeff Schnitzer

unread,
Nov 2, 2012, 1:41:39 PM11/2/12
to objectify...@googlegroups.com
There is not currently any plan.  If you want to build some sort of parser, we might consider including it... but this is a nontrivial feature.

Xybrek

unread,
Nov 2, 2012, 4:32:47 PM11/2/12
to objectify...@googlegroups.com, je...@infohazard.org
I've done parsers in the past but that was with C++, but I can consider doing this. Also, I am pretty sure that SQL-like queries may not be much suitable for building query objects.
I may need to fully understand the full extent feature of the Query class, the depth and the full list of possible query combinations. I find this idea really fun, not considering that we really need this for our project coz' we have a system that is built on triggering SQL scripts in the backend, and we need to reuse it with our AppEngine port of the system.

Xybrek

unread,
Nov 2, 2012, 4:37:21 PM11/2/12
to objectify...@googlegroups.com, je...@infohazard.org
While thinking of doing this feature, for me to move on with our project, is it possible that JPA and Objectify to work together, that is persisted Entities using Objectify be queried by JPA and vice versa?

On Saturday, November 3, 2012 1:41:41 AM UTC+8, Jeff Schnitzer wrote:

Jeff Schnitzer

unread,
Nov 3, 2012, 11:41:55 AM11/3/12
to objectify...@googlegroups.com
You should have no trouble using JPA and Objectify in the same project as long as you keep the entity classes in sync.  Although, if you are going to go through that trouble, why not just use JPA?

The only major impedance mismatches will be polymoprhism, some edge cases in @Embed collections (specifically null handling), and partial indexes (which don't exist in JPA).

Jeff

Xybrek

unread,
Nov 9, 2012, 5:54:28 AM11/9/12
to objectify...@googlegroups.com, je...@infohazard.org
This is actually one of my "crazy" idea mainly because we have an old system that I ported with AppEngine and it only knows JDBC and JPA queries, but I don't want to do JPA as it is very hard to maintain, I'd rather use Objectify. 
Reply all
Reply to author
Forward
0 new messages