Hi again Divyank,
I was able to run that latest example, and it's actually working for me.
I did split the example into two classes (Car and Activity) though, so I could run in my IDE. I also added a toString() method in the Car class. But I think otherwise it's the same.
When I run it, it prints the following to the console:
Car{name='mercedes', featureBulletPoints=[att, mehngi], randomMap={a=bmwMap}}
I'll paste the source of the two classes which work for me below, so you can compare this with the version which fails for you.
// Activity.java
package com.googlecode.cqengine.temp;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.googlecode.cqengine.ConcurrentIndexedCollection;
import com.googlecode.cqengine.IndexedCollection;
import com.googlecode.cqengine.codegen.AttributeBytecodeGenerator;
import com.googlecode.cqengine.query.parser.sql.SQLParser;
import com.googlecode.cqengine.resultset.ResultSet;
public class Activity {
public static void main(String args[]) {
List<Car> sampleList = new ArrayList<>();
sampleList.add(new Car("mercedes", ImmutableList.of("att", "mehngi"), ImmutableMap.of("a", "bmwMap")));
sampleList.add(new Car("bmw", ImmutableList.of("nice"), ImmutableMap.of("b", "set")));
sampleList.add(new Car("ferrari", ImmutableList.of("bahli att", "sports"), ImmutableMap.of("rando", "anothe")));
sampleList.add(new Car("rolls royce", ImmutableList.of("sirra", "kuch bhi"), ImmutableMap.of("blahh", "hola")));
IndexedCollection<Car> indexedCollection = new ConcurrentIndexedCollection<Car>();
indexedCollection.addAll(sampleList);
SQLParser<Car> sqlParser = SQLParser.forPojoWithAttributes(Car.class, AttributeBytecodeGenerator.createAttributes(Car.class));
ResultSet<Car> results = sqlParser.retrieve(indexedCollection, "SELECT * FROM indexedCollection WHERE name = 'mercedes'");
for(Car car : results) {
System.out.println(car);
}
results.close();
}
}
// Car.java
package com.googlecode.cqengine.temp;
import java.util.List;
import java.util.Map;
public class Car {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getFeatureBulletPoints() {
return featureBulletPoints;
}
public void setFeatureBulletPoints(List<String> featureBulletPoints) {
this.featureBulletPoints = featureBulletPoints;
}
public Map<String, String> getRandomMap() {
return randomMap;
}
public void setRandomMap(Map<String, String> randomMap) {
this.randomMap = randomMap;
}
public String name;
public List<String> featureBulletPoints;
public Map<String, String> randomMap;
Car(String name, List<String> featureBulletPoints, Map<String, String> map) {
this.name = name;
this.featureBulletPoints = featureBulletPoints;
this.randomMap = map;
}
@Override
public String toString() {
return "Car{" +
"name='" + name + '\'' +
", featureBulletPoints=" + featureBulletPoints +
", randomMap=" + randomMap +
'}';
}
}
One additional possibility is that there might be a dependency conflict in your application - so maybe you could double-check that CQEngine is being run with the correct versions of it's dependencies?
Best regards,
Niall