我正在针对 MySql 中的 World 数据库测试 QueryDSL。我可以将数据作为列表检索,但无法将其作为列表返回。我正在通过 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