-->
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: Wrong Column names
PostPosted: Wed Apr 30, 2008 10:52 am 
Newbie

Joined: Wed Apr 30, 2008 10:36 am
Posts: 4
Location: Germany
Hi,

I have a native sql query like this
Code:
SELECT DISTINCT table1.id ,  table2.id AS table2id
    FROM table1 LEFT OUTER JOIN table2 ON cond1 AND condi2. ....


When i get the result array .. the two row object which should be having the following data
row[0] tale1.id
row[1] tale2.id has instead this values

row[0] tale1.id
row[1] tale1.id

Thats is because the column name is the same 'id' looking at the hibernate source code i found out that in class org.hibernate.loader.custom.CustomLoader and subclass within that ScalarResultColumnProcessor prepares the metadata and the alias name .. and in there
Code:
public void performDiscovery(Metadata metadata, List types, List aliases) throws SQLException {
         if ( alias == null ) {
            alias = metadata.getColumnName( position );
         }
         else if ( position < 0 ) {
            position = metadata.resolveColumnPosition( alias );
         }
         if ( type == null ) {
            type = metadata.getHibernateType( position );
         }
         types.add( type );
         aliases.add( alias );
      }


So it does metadata.getColumnName(position) which in my case returns id for both the returned columns .. wont it be better to lookup for columnlabel instead of columnname
like metadata.getColumnLabel('posiiton') ..?

Should i post this as a bug on JIRA ?

any help would be appreciated ..
Imran


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.