-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Get records from database views
PostPosted: Wed Dec 03, 2008 9:34 am 
Newbie

Joined: Thu Nov 13, 2008 8:21 am
Posts: 8
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.