Mule 查询语言 - Order by 子句
寻找与 java 对象一起使用的查询语言。找到了 MQL(Mule 查询语言)。 它处于测试阶段,我没有找到太多文档。尝试了一些东西,例如 where 子句和 select 子句。但订单条款不起作用。
List users = new ArrayList();
users.add(new User("Dan", "[email protected]",2,13000 , address));
address = new Address("International pkway","Atlatna","GA","USA");
users.add(new User("Joe", "[email protected]", 1,14000, address));
users.add(new User("John", "[email protected]", 1,16000, address));
users.add(new User("Scott", "[email protected]", 1,15000, address));
users.add(new User("Andy", "[email protected]", 1,7000, address));
Query query = new QueryBuilder()
.as("p")
.orderby("income")
// .max(3)
.where(eq(property("companyId"), 1))
.select(newObject()
.set("name", "name")
.set("income", "income")
.set("email", "email")).build();
Collection result1 = query.execute(users);
如果有人有幸使用 MQL 或建议任何其他好的框架来查询 java 对象,请告诉我。
Another error – when the result set is not hashmap.
Exception in thread “main” java.lang.ClassCastException: com.mql.test.User cannot be cast to java.util.Map
at com.mulesoft.mql.impl.OrderByComparator.compare(OrderByComparator.java:11)
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
at java.util.Collections.sort(Collections.java:159)
at com.mulesoft.mql.Query.order(Query.java:214)
at com.mulesoft.mql.Query.execute(Query.java:189)
List persons = getPersons();
Query query = new QueryBuilder()
// .where(and(eq(property(“division”), “Sales”),
// eq(property(“firstName”), “Joe”)))
.orderby(“income”)
.max(3)
.build();
Looking for query language to work with java objects. Found MQL ( Mule Query Language ).
It's in beta, I didn't find much documentation. tried couple of things like where clause and select clause. But order clause is not working.
List users = new ArrayList();
users.add(new User("Dan", "[email protected]",2,13000 , address));
address = new Address("International pkway","Atlatna","GA","USA");
users.add(new User("Joe", "[email protected]", 1,14000, address));
users.add(new User("John", "[email protected]", 1,16000, address));
users.add(new User("Scott", "[email protected]", 1,15000, address));
users.add(new User("Andy", "[email protected]", 1,7000, address));
Query query = new QueryBuilder()
.as("p")
.orderby("income")
// .max(3)
.where(eq(property("companyId"), 1))
.select(newObject()
.set("name", "name")
.set("income", "income")
.set("email", "email")).build();
Collection result1 = query.execute(users);
Please let me know , if any one has luck playing with MQL or suggest any other good framework to query java objects.
Another error – when the result set is not hashmap.
Exception in thread “main” java.lang.ClassCastException: com.mql.test.User cannot be cast to java.util.Map
at com.mulesoft.mql.impl.OrderByComparator.compare(OrderByComparator.java:11)
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
at java.util.Collections.sort(Collections.java:159)
at com.mulesoft.mql.Query.order(Query.java:214)
at com.mulesoft.mql.Query.execute(Query.java:189)
List persons = getPersons();
Query query = new QueryBuilder()
// .where(and(eq(property(“division”), “Sales”),
// eq(property(“firstName”), “Joe”)))
.orderby(“income”)
.max(3)
.build();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我查看了mql源代码。
OrderByComparator
类中存在错误(拼写错误)。应该是:
I looked at the mql source code. We have a bug (typo) in the
OrderByComparator
class.should be: