views:

25

answers:

1

Hi, I'm working with App Engine(Java/JDO) and are trying to do some querying with lists.

So I have the following class:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class MyEntity
{
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  Key key;

  @Persistent
  List<String> tags = new ArrayList<String>();

  @Persistent
  String otherVar;
}

The following JDO-QL works for me:

( tags.contains('a')  ||  tags.contains('b')  ||  tags.contains('c')  ||  tags.contains('d') ) && otherVar > 'a' && otherVar < 'z'

This seem to return all results where tags has one or more strings with one or more of the given values and together with the inequality search on otherVar

But the following do not work:

(tags.contains('a')  || tags.contains('_a'))  &&  (tags.contains('b')  || tags.contains('_b')) && otherVar > 'a' && otherVar < 'z'

In this case I want all hits where there is at least one a (either a or _a) and one b (either b or _b) together with the inequality search as before.

But the problem is that I also get back the results where there is a but no b, which is not what I want.

Maybe I have missed something obvious, or done a coding error, or possibly there is a restriction on how you can write these queries in appengine, so any tips or help would be very welcome.

Regards Klas

A: 

Ok, so the short answer seems to be that is is not possible to do this today in App Engine. I have made a workaround for this that works for my unique situation, but it is not a solution for all situations so I will not post it here.

If you need a query like this, think about restructuring your datamodel..

KlasE