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: SQL alias & createNativeQuery
PostPosted: Mon Feb 01, 2010 10:16 am 
Newbie

Joined: Mon Feb 01, 2010 9:29 am
Posts: 9
Is there any example how to use SQL alias whit Hibernate, the problem is when retrieving result.
I have two columns with same name and Hibernate doesn't right value.

Code:
String sql = "SELECT uporabniki.id, status.vrednost, host.vrednost "
  + "FROM uporabniki "
  + "LEFT JOIN sif_upostat AS status ON status.id=uporabniki.status "
  + "LEFT JOIN cluster_hosts AS host ON host.id=uporabniki.chost_id "
  + "WHERE uporabniki.id=10"
Query arisQuery = emAris.createNativeQuery(sql);
List arisResult = arisQuery.getResultList();

// retrive data
for(int i = 0; i < arisResult.size(); i++){
   Object[] rs = (Object[])arisResult.get(i);
   if(rs.length == 3){
      String status = rs[2];
      String host = rs[3];
    Bug: this values are the same 
   }


So is Hibernate have problems retrieving column's whith same name?

Is there the simple way to solve this, without mapping's?
Regards, Tomaz


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.