Reputation: 1
I have this code and I expected that when I run !table command in sqlline.bat I will see table called Person, but there is no table.
What I have to do to see the table there? Am I expecting correctly, that there should be created table automatically for each cache?
Thank you
class Program
{
static void Main()
{
var cfg = new IgniteConfiguration
{
BinaryConfiguration = new BinaryConfiguration(typeof(Person),
typeof(PersonFilter))
};
IIgnite ignite = Ignition.Start(cfg);
ICache<int, Person> cache = ignite.GetOrCreateCache<int, Person>("persons");
cache[1] = new Person { Name = "John Doe", Age = 27 };
cache[2] = new Person { Name = "Jane Moe", Age = 43 };
var scanQuery = new ScanQuery<int, Person>(new PersonFilter());
IQueryCursor<ICacheEntry<int, Person>> queryCursor = cache.Query(scanQuery);
foreach (ICacheEntry<int, Person> cacheEntry in queryCursor)
Console.WriteLine(cacheEntry);
Console.ReadKey();
}
}
class Person
{
[QuerySqlField]
public string Name { get; set; }
[QuerySqlField]
public int Age { get; set; }
public override string ToString()
{
return $"Person [Name={Name}, Age={Age}]";
}
}
class PersonFilter : ICacheEntryFilter<int, Person>
{
public bool Invoke(ICacheEntry<int, Person> entry)
{
return entry.Value.Age > 30;
}
}
Upvotes: 0
Views: 27
Reputation: 3017
SQL table shouldn't be created automatically for the cache. To add SQL table, you should define the schema: https://apacheignite-sql.readme.io/docs/schema-and-indexes
It can be done using annotations, QueryEntiny configuration, or by creating the cache using DDL(CREATE TABLE command).
Upvotes: 1