ignite中的sql查询
2016-06-12 15:14
253 查看
ignite中进行sql查询需要对要查询的cache和字段进行配置,可以在xml中配置,也可以在代码中配置或进行注解,我用的是xml配置:
其中keyTpye和ValueType配置就是cache中储存的k和v配置
dao查询代码:
得到的CacheEntryImpl可以进行遍历就得到了需要的东西.
<!-- 配置cache --> <property name="cacheConfiguration"> <list> <bean class="org.apache.ignite.configuration.CacheConfiguration"> <property name="name" value="task_template" /> <property name="cacheMode" value="PARTITIONED" /> <property name="atomicityMode" value="TRANSACTIONAL" /> <property name="backups" value="2" /> <property name="queryEntities"> <list> <bean class="org.apache.ignite.cache.QueryEntity"> <property name="keyType" value="java.lang.Integer" /> <property name="valueType" value="com.domain.read.TaskTemplate" /> <property name="fields"> <map> <entry key="taskTemplateId" value="java.lang.Integer" /> </map> </property> <property name="indexes"> <list> <bean class="org.apache.ignite.cache.QueryIndex"> <constructor-arg value="taskTemplateId" /> </bean> </list> </property> </bean> </list> </property> </bean> </list> </property>
其中keyTpye和ValueType配置就是cache中储存的k和v配置
dao查询代码:
public List<CacheEntryImpl> queryAll() { SqlQuery sql = new SqlQuery(TaskTemplate.class, "taskTemplateId <> -1"); return cache().query(sql).getAll(); }
得到的CacheEntryImpl可以进行遍历就得到了需要的东西.
相关文章推荐
- Mysql配置文件中设置字符集编码
- sql view学习
- 数据库原理(六)--关系数据理论
- ORACLE 专用服务器模式(DEDICATED)与共享服务器模式(SHARE)的区别
- 数据库原理(五)--关系数据库标准语言SQL(二)
- 数据库原理(四)--关系数据库标准语言SQL(一)
- apache+tomcat+Jfinal 2.2+dubbo2.5.4+zookeeper3.3.6 +redis+druid 分布式(集群)部署成功的一点心得(二)
- MySQL 三种关联查询的方式: ON vs USING vs 传统风格
- 数据库原理(三)--关系数据库
- Laravel 5的redis哨兵(sentinel)支持
- 数据库原理(二)--数据模型
- plsql调试存储过程单步不能进入断点
- SQL语句order by两个字段同时排序
- SQL常用函数
- 数据库原理(一)--数据库课程导入
- Oracle存储过程基本语法 存储过程
- PostgreSQL中数据库,表,等对象的oid与对象名的对应关系
- SQL语法
- springmvc整合redis的小案例
- SQL查询——示列代码(二)