setting value from sql query to object
select pb.id,
p.name,
pb.batchName,
pb.batchCode,
s.detail,pb.program_id,
pb.session_id,
si.typ开发者_JS百科eDescp,
si.id
from programBatch_info pb
join program p on pb.program_id=p.id
join session_info s on pb.session_id=s.id
join semester_info si on si.id=pb.semInfo_id
Here the name of first and last columns is 'id' so when I retrieve the values of this query first column object and last column object return the same value.But when I change the 'si.id' to 'pb.semInfo_id' the name of last column is'semInfo_id' and hence the correct values is retrieved. I tried this native query in hibernate platform. Am I conceputally wrong or what is the actual case??
Not sure the question but try this:
select pb.id,
p.name,
pb.batchName,
pb.batchCode,
s.detail,pb.program_id,
pb.session_id,
si.typeDescp,
si.id as [si_id]
from programBatch_info pb
join program p on pb.program_id=p.id
join session_info s on pb.session_id=s.id
join semester_info si on si.id=pb.semInfo_id
This is the syntax to specify a new column name.
精彩评论