Hi Igor,
I was able to fix the issue, what I did is I removed the <property
name="cacheConfiguration"> from the xml.
Now I can query the cache, but the problem is only the string columns data
are showng (ie. firstName, lastName & resume ). The columns with Double,
Long Integer are not coming.
Following is the java code am using:
public class Person implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1167624889662198398L;
/** */
private static final AtomicLong ID_GEN = new AtomicLong();
/** Person ID (indexed). */
@QuerySqlField(index = true)
public Long id;
/** Organization ID (indexed). */
@QuerySqlField(index = true)
public Long orgId;
/** First name (not-indexed). */
@QuerySqlField
public String firstName;
/** Last name (not indexed). */
@QuerySqlField
public String lastName;
/** Resume text (create LUCENE-based TEXT index for this field). */
@QueryTextField
public String resume;
/** Salary (indexed). */
@QuerySqlField(index = true)
public double salary;
/** Custom cache key to guarantee that person is always collocated with
its organization. */
private transient AffinityKey<Long> key;
public Person(Organization org, String firstName, String lastName,
double salary, String resume) {
// Generate unique ID for this person.
id = ID_GEN.incrementAndGet();
orgId = org.id();
this.firstName = firstName;
this.lastName = lastName;
this.salary = salary;
this.resume = resume;
}
public Person(Long id, Long orgId, String firstName, String lastName,
double salary, String resume) {
this.id = id;
this.orgId = orgId;
this.firstName = firstName;
this.lastName = lastName;
this.salary = salary;
this.resume = resume;
}
public Person(Long id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
public static void main(String[] args) throws IgniteException {
try (Ignite ignite = Ignition.start("config/test-odbc.xml")) {
CacheConfiguration<Long, Organization> orgCacheCfg = new
CacheConfiguration<>("Organization");
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
CacheConfiguration<AffinityKey<Long>, Person>
personCacheCfg =
new CacheConfiguration<>("Person");
personCacheCfg.setCacheMode(CacheMode.PARTITIONED); //
Default.
personCacheCfg.setIndexedTypes(AffinityKey.class,
Person.class);
// Populate cache.
try (
IgniteCache<Long, Organization> orgCache =
ignite.getOrCreateCache(orgCacheCfg);
IgniteCache<AffinityKey<Long>, Person>
personCache =
ignite.getOrCreateCache(personCacheCfg)
) {
orgCache.clear();
// Organizations.
Organization org1 = new Organization("ApacheIgnite");
Organization org2 = new Organization("Other");
orgCache.put(org1.id(), org1);
orgCache.put(org2.id(), org2);
personCache.clear();
// People.
Person p1 = new Person(org1, "John","Doe", 2000,"Fresher");
Person p2 = new Person(org1,"Jane", "Wilson", 3000,
"Experienced");
Person p3 = new Person(org2, "Edward", "Smith", 2000,
"Intermediate");
Person p4 = new Person(org2, "David", "Warn", 5000,
"Expert");
Person p5 = new Person(org2, "Tim", "Cook", 5000, "Expert");
personCache.put(p1.key(), p1);
personCache.put(p2.key(), p2);
personCache.put(p3.key(), p3);
personCache.put(p4.key(), p4);
personCache.put(p5.key(), p5);
}
}
}
public AffinityKey<Long> key() {
if (key == null)
key = new AffinityKey<>(id, orgId);
System.out.println("Key==="+key);
return key;
}
}
Thanks
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Cannot-get-the-data-in-Tableau-tp6876p7131.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.