Thank you for your reply! This method works, but I have another question. If 
the Person class has a member which is another class, say Address. Class 
Address has two members int streetNo and String streetName. When I create the 
cache, I can use QueryEntity to map the members of Address to table 
columns/fields. How should I write the "alter table Person" statement if I want 
to add a new member to class Address after the cache has been created? Thank 
you!


-----Original Message-----
From: slava.koptilin [mailto:[email protected]] 
Sent: 2018年6月20日 14:50
To: [email protected]
Subject: RE: SQL cannot find data of new class definition

Hello,

> Can I add fields without restarting the cluster?
Yes, It can be done via DDL command, as Ilya Kasnacheev mentioned.

Let's assume that you created a cache:
        CacheConfiguration cfg = new CacheConfiguration(PERSON_CACHE_NAME)
            .setIndexedTypes(Long.class, Person.class);

        IgniteCache cache = ignite.getOrCreateCache(cfg);

where the Person class has two fields 'id' and 'firstName'.

after that, you want to add a new field, for example, 'secondName'.
    // please take a look for the details:
https://apacheignite-sql.readme.io/docs/alter-table
    String ddl = "alter table Person add column secondName varchar";

    // execute the DDL command
    cache.query(new SqlFieldsQuery(ddl)).getAll();

    // new field should be queryable
    Iterator iter = cache.query(new SqlFieldsQuery("select secondName from 
Person")).getAll());

hope it helps.

Thanks!



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to