google-code-export / twig-persist

Automatically exported from code.google.com/p/twig-persist
1 stars 1 forks source link

ClassCastException when when using a Set with an IN filter #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to perform a query such as this:

Set<String> mySet = new HashSet<String>();
// ... populate the set with some values
Iterator<MyModel> iter = 
datastore.find().type(MyModel.class).addFilter("myField", FilterOperator.IN, 
mySet).now();

The above, generates the below exception. This worked in the tagged version of 
Twig 2.0. It no longer works in the trunk. Fortunately, I am able to get around 
this by using google collections to transform my Set into a List, but I have 
this kind of code throughout my app since I typically prefer Sets when 
filtering by a collection of values.

java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.List
        at com.google.code.twig.standard.RelationTranslator$1.get(RelationTranslator.java:130)
        at com.google.code.twig.standard.RelationTranslator$1.get(RelationTranslator.java:125)
        at com.google.code.twig.standard.StandardCommonFindCommand.addFilter(StandardCommonFindCommand.java:118)

Original issue reported on code.google.com by barbedwi...@gmail.com on 10 Nov 2010 at 4:37

GoogleCodeExporter commented 9 years ago
I am not able to run a build at the moment.  If you change the source to cast 
to a Collection instead of List does that solve the issue?

Original comment by jdpatterson on 10 Nov 2010 at 3:13

GoogleCodeExporter commented 9 years ago

Original comment by jdpatterson on 25 Mar 2011 at 3:48