OpenJPA 1.2.2、WebSphere 7(Java EE 5)
orm.xmlで定義されたnamed-native-queryを使用して、テーブルをPOJO(エンティティではありません!)にマップしようとしています。
<named-native-query name="myNativeQuery" result-class="foo.bar.PojoBean">
<query>
SELECT col_one AS colOne, col_two AS colTwo, col_three AS colThree
FROM myTable WHERE id = 42
</query>
</named-native-query>
PojoBeanは、String getter/settersとempty-argumentコンストラクターを備えた最終クラスです。
public final class PojoBean implements java.io.Serializable {
public PojoBean() {
}
public String getColOne() { ... }
public void setColOne(String colOne) { ... }
...
}
クエリを作成するとき:
EntityManager myEntityManager = ...
myEntityManager.createNamedQuery("myNativeQuery");
例外が発生しました(読みやすくするためにフォーマットされています):
<openjpa-1.2.2-r422266:898935 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException:
Result type "class foo.bar.PojoBean" does not have any public fields or setter methods for the projection or aggregate result element "null",
nor does it have a generic put(Object,Object) method that can be used,
nor does it have a public constructor that takes the types null.
どういう意味ですか ?
より詳しい情報:
- PojoBeanの実装は変更できず、finalクラスも拡張できません。
- EntityManager.createNativeQuery(...)を使用してJavaからクエリを実行することは機能しますが、これはオプションではありません。
ありがとうございました、