1
寻找查询语言以使用java对象。找到MQL(Mule查询语言)。 它在测试版中,我没有找到很多文档。尝试过几件事情,比如where子句和select子句。但订单条款不起作用。Mule查询语言 - 按条款排序
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();