3

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

4

1 に答える 1

2

ここhttp://blog.mysema.com/2011/01/querying-in-sql-with-querydsl.htmlBeanクラス生成で説明されているようにBeanタイプを生成する必要があります。

于 2012-08-11T07:41:03.220 に答える