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