[英]QueryDsl MongoDB - Accessing Deeply Nested Object for Query
[英]QueryDSL simple query will not cast to object
我在MySql中对World数据库测试QueryDSL。 我可以将数据检索为List,但我无法将其作为List返回。 我通过SQL查询,没有别的。 这就是我所拥有的。
private void getSomething(Connection connection) {
QCountry country = QCountry.country;
SQLTemplates dialect = new HSQLDBTemplates();
SQLQuery query = new SQLQueryImpl(connection, dialect);
//List<Object[]> countries = query.from(country).list(country.all());
List<QCountry> countries = query.from(country).list(country);
System.out.println(countries);
try {
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我收到此错误: java.lang.IllegalArgumentException: RelationalPath based projection can only be used with generated Bean types
您需要生成bean类型,如此处所述http://blog.mysema.com/2011/01/querying-in-sql-with-querydsl.html在Bean类生成下 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.