You need to tell the SQL engine about your POJO. There are number of ways of
doing that, but one example would be:
val cacheConfiguration = new CacheConfiguration[Integer,DataX]()
val valQE = new QueryEntity()
valQE.setKeyFieldName("key")
valQE.setKeyType("java.lang.Integer")
valQE.setValueType("DataX")
valQE.addQueryField("key", "java.lang.Integer", "key")
valQE.addQueryField("value","java.lang.String","value")
cacheConfiguration.setQueryEntities(java.util.Arrays.asList(valQE))
cacheConfiguration.setName("tdCache")
val dtCache = ignite.getOrCreateCache(cacheConfiguration)
Then the SQL will work:
0: jdbc:ignite:thin://127.0.0.1> select * from "tdCache".DATAX;
+--------------------------------+--------------------------------+
| KEY | VALUE |
+--------------------------------+--------------------------------+
| 1 | Stephen |
+--------------------------------+--------------------------------+
1 row selected (0.02 seconds)
0: jdbc:ignite:thin://127.0.0.1>
You can also use annotations, define this in XML or use a SQL CREATE TABLE
statement.
Regards,
Stephen
> On 4 Nov 2019, at 01:35, BorisBelozerov <[email protected]> wrote:
>
> How can I insert data by sqlline.bat?
> I use class DataX:
> public class DataX {
> private Integer key;
> private String value;
> public DataX(int key,String value) {
> this.key=key;
> this.value=value;
> }
> public int getKey() {
> return key;
> }
> public void setKey(int key) {
> this.key=key;
> }
> public String getValue() {
> return value;
> }
> public void setValue(String value) {
> this.value=value;
> }
> }
>
> and a cache named dtCache:
> IgniteCache<Integer, DataX> dtCache=ignite.getOrCreateCache("dtCache");
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/