[hibernate-dev] any suggestion about how to fix HHH-5992?
Max Rydahl Andersen
max.andersen at redhat.com
Tue Nov 29 12:37:59 EST 2011
> I agree we should not do any magic on a native query; but following
> this reasoning just anything should be possible, and I wouldn't expect
> Hibernate to apply such magic to the results either.
> Why is it even looking at names in the resultset? As a user I'd want
> it to just return the same ordered sequence of values.
At the time of original implementation there wasn't any other way to do the mapping as I recall.
I guess in this very special case (no scalars, nor entity mappings) adding on the query it could be handled differently.
Note though that we need to ensure if you apply a result transformer to this query it will actually return something sensible
(i.e. named aliases for a map vs just indexes)
The rearranging of hibernate core might allow for handling this now but I'm not uptodate on that.
> I would consider it very important to allow a full "jdbc fallback"
> experience, otherwise instead of being a nice tool it becomes an
> impediment and users will rightfully hate you.
> On 29 November 2011 15:25, Max Rydahl Andersen <max.andersen at redhat.com> wrote:
>> the original idea of the native sql approach is to avoid/reduce doing anything magical with the query since
>> there is no way to fix these generally without a full sql parser.
>> So I would say it works as expected.
>> On Nov 29, 2011, at 11:59, Strong Liu wrote:
>>> id username
>>> 1 stliu
>>> 2 gail
>>> for example a native query sql "select v1.username, v2.username from T_User v1, T_User v2 where v1.id = '1' and v2.id = '2'"
>>> but the query returns ["stliu", "stliu"] instead of the expected ["stliu", "gail"]
>>> this is because hibernate uses column alias (in this case, both are "username") to get the result from ResultSet, and since the two result in RS are all keyed by "username"
>>> should we generate a alias for each like hql does?
>>> Best Regards,
>>> Strong Liu <stliu at hibernate.org>
>>> hibernate-dev mailing list
>>> hibernate-dev at lists.jboss.org
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
More information about the hibernate-dev