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