I want to read records from a database view called "ArVIfRdeRdtWagen".
The view is generated as a the actually JPA Entity called "ArVIfRdeRdtWagen" and the associated composite key "ArVIfRdeRdtWagenId".
To read the records I execute:
Code:
public Collection<ArVIfRdeRdtWagen> findWagenByNummer(String nummer) {
Query query = em
.createQuery("SELECT a FROM ArVIfRdeRdtWagen a");
return (Collection<ArVIfRdeRdtWagen>) query.getResultList();
}
Hibernate creates following statement:
Code:
select
*
from
( select
arvifrderd0_.SATZ_ID as SATZ1_807_,
arvifrderd0_.WAGEN_NR as WAGEN2_807_,
arvifrderd0_.KZ_PW as KZ3_807_,
arvifrderd0_.GATTUNG_BEZ as GATTUNG4_807_,
arvifrderd0_.ANZAHL_ACHSEN as ANZAHL5_807_,
arvifrderd0_.ATV_CODE as ATV6_807_,
arvifrderd0_.EMASSE as EMASSE807_
from
AR_V_IF_RDE_RDT_WAGEN arvifrderd0_ )
where
rownum <= ?
that delivers a list filled with the exact amount of null records which match to the query.
If I execute the generated query on the database I got the appropriate records.
When I now change the query to:
Code:
SELECT a.id.anzahlAchsen, a.id.atvCode, a.id.emasse, a.id.gattungBez, a.id.kzPw, a.id.satzId, a.id.wagenNr FROM ArVIfRdeRdtWagen a
I get a list of records represented by class Object, which is apparently not what i expect.
How do I get a list of the expected instances of type "ArVIfRdeRdtWagen"?
I use Eclipse 3.3.x, ejb3-persistence, oracle 10g, Java 1.5.0_14