Hi,
I am getting column not found exception when I run SqlQuery. not sure why.
below is my code. When I query using name and Id, I get results, When I use
date or localDate types to query, I get exception
" Caused by: org.h2.jdbc.JdbcSQLException: Column "COMPANY.INAGURATION" not
found; SQL statement:"
I am not able to understand what is the reason ?
Could you please help.
public class Company {
@QuerySqlField(index=true)
private int id ;
@QuerySqlField(index=true)
private String name;
@QuerySqlField(index=true)
private LocalDate startDate;
@QuerySqlField(index=true)
private Date inaguration;
public Company(int id , String name ,LocalDate startDate,Date
inaguration) {
this.id= id;
this.name=name;
this.startDate=startDate;
this.inaguration = inaguration;
}
.....getter/setters
public static void main(String[] args) {
try(Ignite ignite =
Ignition.start("examples/config/example-ignite.xml")) {
CacheConfiguration<Integer, Company> ccfg = new
CacheConfiguration<>("companies");
ccfg.setIndexedTypes(Integer.class, Company.class);
IgniteCache<Integer, Company> companies =
ignite.getOrCreateCache(ccfg);
Company c1 = new Company(Integer.valueOf(1),
"company1",LocalDate.of(1990, 9, 3), new Date(2016, 03, 03));
Company c2 = new Company(Integer.valueOf(2),
"company2",LocalDate.of(1995, 6, 1), new Date(2016, 03, 03));
Company c3 = new Company(Integer.valueOf(3),
"company3",LocalDate.of(1997, 8, 5), new Date(2016, 03, 03));
Company c4 = new Company(Integer.valueOf(4),
"company4",LocalDate.of(2005, 3, 21), new Date(2016, 03, 03));
Company c5 = new Company(Integer.valueOf(5),
"GG",LocalDate.of(2010, 2, 23), new Date(2016, 03, 03));
Company c6 = new Company(Integer.valueOf(6),
"APache",LocalDate.of(2013, 9, 13), new Date(2016, 03, 03));
companies.put(c1.getId(), c1);
companies.put(c2.getId(), c2);
companies.put(c3.getId(), c3);
companies.put(c4.getId(), c4);
companies.put(c5.getId(), c5);
companies.put(c6.getId(), c6);
String sortby = "id";
String orderBy = "desc";
String startdate = "3Mar16";
String sql ="select * from Company where
Company.inaguration=? order by Company."+sortby+" "+orderBy;
SqlQuery<Integer, Company> query1 = new
SqlQuery<>(Company.class, sql);
query1.setArgs(startdate);
List<Entry<Integer, Company>> res1=
companies.query(query1).getAll();
for (Entry<Integer, Company> entry : res1) {
System.out.println(entry.getKey()+ "
"+entry.getValue());
}
}
}