cqengine
2021/7/22 6:07:35
本文主要是介绍cqengine,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.参考:
https://www.cnblogs.com/tankaixiong/p/12920667.html
2.语法
SQL
public static void main(String[] args) { SQLParser<Car> parser = SQLParser.forPojoWithAttributes(Car.class, createAttributes(Car.class)); IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>(); cars.addAll(CarFactory.createCollectionOfCars(10)); ResultSet<Car> results = parser.retrieve(cars, "SELECT * FROM cars WHERE (" + "(manufacturer = 'Ford' OR manufacturer = 'Honda') " + "AND price <= 5000.0 " + "AND color NOT IN ('GREEN', 'WHITE')) " + "ORDER BY manufacturer DESC, price ASC"); for (Car car : results) { System.out.println(car); // Prints: Honda Accord, Ford Fusion, Ford Focus } } 3.like
%xxx%:查询username字段中包含xxx的记录。
select * from user where username like '%xxx%';
%xxx:查询username字段中以xxx结尾的记录。
select * from user where username like '%xxx';
xxx%:查询username字段中以xxx开头的记录。
select * from user where username like 'xxx%';
4.https://blog.csdn.net/ldc5306590/article/details/53705319?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control
String sqlString="select * from tb_wf_main where trim(WF_NAME) = ' " + wfName.trim() + " ' ";
5.
package com.huawi; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * WHERE (( name LIKE '%1%' OR name LIKE '%2%' ) AND age >= 20 ) ORDER BY manufacturer DESC, price ASC */ public class AAA { public static void main(String[] args) { String head = "WHERE ("; String end = " ) ORDER BY manufacturer DESC, price ASC"; // list ArrayList<String> sqlLists = new ArrayList<>(); List<String> strings = Arrays.asList("1", "25"); String listCenter = parseListSql(strings); sqlLists.add(listCenter); // 数值 StringBuffer stringBuffer1 = new StringBuffer(); String ageCenter = stringBuffer1.append(" AND age ").append(" >= ").append(20).toString(); sqlLists.add(ageCenter); // 字符 StringBuffer stringBuffer2 = new StringBuffer(); String StringCenter = stringBuffer2.append(" AND addr ").append(" = ").append("'" + "anhui" + "'").toString(); sqlLists.add(StringCenter); StringBuffer stringBufferFinal = new StringBuffer(); for (String s : sqlLists) { stringBufferFinal.append(s); } String finalString = head + stringBufferFinal.toString() + end; System.out.println(finalString); } public static String parseListSql(List<String> strings) { StringBuffer stringBuffer = new StringBuffer(); for (String s : strings) { stringBuffer.append("name").append(" LIKE ").append("'" + '%' + ',' + s + ',' + '%' + "'").append(" OR "); } String center = stringBuffer.append(")").toString(); center = center.substring(0, center.length() - 5); center = "( " + center + " )"; return center; } }
这篇关于cqengine的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-22怎么通过控制台去看我的页面渲染的内容在哪个文件中呢-icode9专业技术文章分享
- 2024-12-22el-tabs 组件只被引用了一次,但有时会渲染两次是什么原因?-icode9专业技术文章分享
- 2024-12-22wordpress有哪些好的安全插件?-icode9专业技术文章分享
- 2024-12-22wordpress如何查看系统有哪些cron任务?-icode9专业技术文章分享
- 2024-12-21Svg Sprite Icon教程:轻松入门与应用指南
- 2024-12-20Excel数据导出实战:新手必学的简单教程
- 2024-12-20RBAC的权限实战:新手入门教程
- 2024-12-20Svg Sprite Icon实战:从入门到上手的全面指南
- 2024-12-20LCD1602显示模块详解
- 2024-12-20利用Gemini构建处理各种PDF文档的Document AI管道