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.  [ 3 posts ] 
Author Message
 Post subject: Select clause contains too much data
PostPosted: Tue Dec 12, 2006 9:36 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Hibernate 3.0.5

All,

I'm generate a Query using the Criteria API using the Example API and the Restrictions.idEQ() method.

The result of such a query looks as follows:

Code:
select this_.ID                               as ID4_,
          this_.DT_MOD                           as DT2_61_3_,
          this_.UITGEVOERD_ARTS                  as UITGEVOERD3_61_3_,
          this_.UITGEVOERD_ASSISTENT             as UITGEVOERD4_61_3_,
          this_.DT_UITGEVOERD                    as DT5_61_3_,
          this_.WKN_PAR_ID                       as WKN6_61_3_,
          this_.USER_CREA                        as USER7_61_3_,
          this_.USER_MOD                         as USER8_61_3_,
          this_.USER_DEL                         as USER9_61_3_,
          this_.DT_CREA                          as DT10_61_3_,
          this_.DT_DEL                           as DT11_61_3_,
          werknemer1_.ID                         as ID0_,
          werknemer1_.DT_MOD                     as DT2_11_0_,
          werknemer1_.TAAL_CD                    as TAAL3_11_0_,
          werknemer1_.NAT_CD                     as NAT4_11_0_,
          werknemer1_.USER_CREA                  as USER5_11_0_,
          werknemer1_.USER_MOD                   as USER6_11_0_,
          werknemer1_.USER_DEL                   as USER7_11_0_,
          werknemer1_.DT_CREA                    as DT8_11_0_,
          werknemer1_.DT_DEL                     as DT9_11_0_,
          werknemer1_.NM_ID                      as NM10_11_0_,
          werknemer1_.TYPE_NAAM_CD               as TYPE11_11_0_,
          werknemer1_.NAAM                       as NAAM11_0_,
          werknemer1_.NAAM2                      as NAAM13_11_0_,
          werknemer1_.VOORNAAM                   as VOORNAAM11_0_,
          werknemer1_.VOORNAAM2                  as VOORNAAM15_11_0_,
          werknemer1_.TITEL_CD                   as TITEL16_11_0_,
          werknemer1_.TITEL_CORR                 as TITEL17_11_0_,
          werknemer1_.NAAM_FON                   as NAAM18_11_0_,
          werknemer1_.DT_GLDG_BEGIN              as DT19_11_0_,
          werknemer1_.DT_GLDG_EINDE              as DT20_11_0_,
          werknemer1_.WKN_ID                     as WKN1_112_0_,
          werknemer1_.RIJKSREG_NR                as RIJKSREG2_112_0_,
          werknemer1_.GESLACHT_CD                as GESLACHT3_112_0_,
          werknemer1_.WERKNEMER_NR               as WERKNEMER4_112_0_,
          werknemer1_.GBRT_PLAATS                as GBRT5_112_0_,
          werknemer1_.DT_GBRT                    as DT6_112_0_,
          werknemer1_.GBRT_LAND                  as GBRT7_112_0_,
          werknemer1_.BLOEDGROEP                 as BLOEDGROEP112_0_,
          werknemer1_.RHESUS                     as RHESUS112_0_,
          werknemer1_.HANDVOORKEUR               as HANDVOO10_112_0_,
          medischein2_.ID                        as ID1_,
          medischein2_.DT_MOD                    as DT2_4_1_,
          medischein2_.AANLEIDING_COMMENTAAR     as AANLEIDING3_4_1_,
          medischein2_.DT_VOORKEUR               as DT4_4_1_,
          medischein2_.DT_UITGEVOERD             as DT5_4_1_,
          medischein2_.UUR_VAN                   as UUR6_4_1_,
          medischein2_.UITGEVOERD_UREN           as UITGEVOERD7_4_1_,
          medischein2_.RESULTAAT                 as RESULTAAT4_1_,
          medischein2_.VERSLAG_CONCLUSIE         as VERSLAG9_4_1_,
          medischein2_.STATUS                    as STATUS4_1_,
          medischein2_.STATUS_DT_VAN             as STATUS11_4_1_,
          medischein2_.FACTURATIESTATUS          as FACTURA12_4_1_,
          medischein2_.USER_CREA                 as USER13_4_1_,
          medischein2_.USER_MOD                  as USER14_4_1_,
          medischein2_.USER_DEL                  as USER15_4_1_,
          medischein2_.DT_CREA                   as DT16_4_1_,
          medischein2_.DT_DEL                    as DT17_4_1_,
          medischein2_.PAR_ID_WKN                as PAR18_4_1_,
          medischein2_.MDW_ID                    as MDW19_4_1_,
          medischein2_.MDW_ID_IN_BEHANDELING_BIJ as MDW20_4_1_,
          medischein2_.IT_ID                     as IT21_4_1_,
          medischein2_.PAR_ID                    as PAR22_4_1_,
          medischein2_.ZIT_ID                    as ZIT23_4_1_,
          medischein2_.MT_ID                     as MT24_4_1_,
          interventi3_.ID                        as ID2_,
          interventi3_.DT_MOD                    as DT2_0_2_,
          interventi3_.AFKORTING                 as AFKORTING0_2_,
          interventi3_.OMSCHRIJVING              as OMSCHRIJ4_0_2_,
          interventi3_.SUPERTYPE                 as SUPERTYPE0_2_,
          interventi3_.FORM_NAAM                 as FORM6_0_2_,
          interventi3_.USER_CREA                 as USER7_0_2_,
          interventi3_.USER_MOD                  as USER8_0_2_,
          interventi3_.USER_DEL                  as USER9_0_2_,
          interventi3_.DT_CREA                   as DT10_0_2_,
          interventi3_.DT_DEL                    as DT11_0_2_,
     from MD_MEDISCHE_TUSSENKOMST this_
    inner join V_WERKNEMER werknemer1_ on this_.WKN_PAR_ID = werknemer1_.ID
    inner join IV_MEDISCHE_INTERVENTIE medischein2_ on this_.ID =
                                                       medischein2_.MT_ID
    inner join IV_INTERVENTIE_TYPE interventi3_ on medischein2_.IT_ID =
                                                   interventi3_.ID
    where (1 = 1)
      and werknemer1_.ID = '9524081C080A48A0E034080020E1F78E'
      and (1 = 1)
      and (interventi3_.SUPERTYPE = 'MO')


but what I actually want is that only the following occurs as the first query returns too much data. The query also takes a bigger amount of time.

Code:
select this_.ID                               as ID4_,
          this_.DT_MOD                           as DT2_61_3_,
          this_.UITGEVOERD_ARTS                  as UITGEVOERD3_61_3_,
          this_.UITGEVOERD_ASSISTENT             as UITGEVOERD4_61_3_,
          this_.DT_UITGEVOERD                    as DT5_61_3_,
          this_.WKN_PAR_ID                       as WKN6_61_3_,
          this_.USER_CREA                        as USER7_61_3_,
          this_.USER_MOD                         as USER8_61_3_,
          this_.USER_DEL                         as USER9_61_3_,
          this_.DT_CREA                          as DT10_61_3_,
          this_.DT_DEL                           as DT11_61_3_,
         from MD_MEDISCHE_TUSSENKOMST this_
    inner join V_WERKNEMER werknemer1_ on this_.WKN_PAR_ID = werknemer1_.ID
    inner join IV_MEDISCHE_INTERVENTIE medischein2_ on this_.ID =
                                                       medischein2_.MT_ID
    inner join IV_INTERVENTIE_TYPE interventi3_ on medischein2_.IT_ID =
                                                   interventi3_.ID
    where (1 = 1)
      and werknemer1_.ID = '9524081C080A48A0E034080020E1F78E'
      and (1 = 1)
      and (interventi3_.SUPERTYPE = 'MO')



Anyone any ideas how to workaround this basic "feature" of hibernate?

Thanx,
Nico


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 12:20 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
You can use Projections to specify the properties you wish to select. Then use a ResultTransformer to place the custom list of properties into a POJO(otherwise, you will get a list of Object[]).

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 1:51 pm 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Yes this is one approach, however I needed a general approach as I generate the complete Criteria and subcriteria based on the MetaData of my Domain model Objects.

I managed to achieve the correct behaviour by using the SQLProjection.

So I did not need to use the ResultTransformer afterwards.

new SQLProjection("{alias}.id Obj_", new String[]{"Obj_"}, Hibernate.entity(MuBusinessObject.class))

Hope this might help other in the future.
Ofcourse if determine the primary key column name not hardcoded as it is here, but I generate it based on the information I have

Nico


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

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.