Java QueryDSL简单查询不会强制转换为对象

Java QueryDSL简单查询不会强制转换为对象,java,querydsl,Java,Querydsl,我正在MySql中对World数据库测试QueryDSL。我可以将数据作为列表检索,但无法将其作为列表返回。我是通过SQL查询的,没有别的。这就是我所拥有的 private void getSomething(Connection connection) { QCountry country = QCountry.country; SQLTemplates dialect = new HSQLDBTemplates(); SQLQuery query = new SQLQueryI

我正在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();
  }
}
private void getSomething(连接){
QCountry country=QCountry.country;
SQLTemplates方言=新的HSQLDBTemplates();
SQLQuery query=新的SQLQueryImpl(连接,方言);
//List countries=query.from(country.List(country.all());
列表国家=查询.from(国家)。列表(国家);
System.out.println(国家);
试一试{
connection.close();
}捕获(SQLE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
我得到这个错误:
java.lang.IllegalArgumentException:基于关系路径的投影只能用于生成的Bean类型

您需要生成Bean类型,如Bean类生成中所述