Forums Register Login

Issue with String types when hibernate returns list of Object arrays

+Pie Number of slices to send: Send
Hi,

I am seeing a wierd issue. My query is retuning the list of obejct arrays; which is fine. However for string type cloumns, it's retuning only the first character.

forexample: if the value in the column is 'bhanu', it's just retreving 'b'.

During the debug when I watch the retuned list; I see that field as Character Object. I am using Db2 database. Can someone explain me the reason for this issue?

And also can we have two bean classes map to one table? i.e.; can I write two hbm xml files for same table but each one map to different bean? May be foolish question. But appreciate the response...

thank you,
bhanu


+Pie Number of slices to send: Send
You're probably not attaching the Java object to the query, but without seeing the query, it's tough to help.
+Pie Number of slices to send: Send
Hi David,

Thank you for responding to my question.

Here is the query:
<sql-query name="bhanu >
<![CDATA[
select status, unit, dr_amount, cr_amount, cr_itm_cnt, dr_itm_cnt, aprvid1, aprvid2, comment
from transaction where trasaction_id= ? AND updt_by_ts < ?
ORDER BY trasaction_id ASC, updt_by_ts DESC
FOR READ ONLY
]]>
</sql-query>

In the above query - status,unit, aprvid1, aprvid2,comment are string fields. If I execute the query against the database for above fileds correct data is coming out...
but when I execute the query through the hibernate code, I get only the first character ...

Executing the query in the as below:
public List getTransactions(String trannum, Date date){
List tranlist=new ArrayList();
Query query = getSession().getNamedQuery("bhanu");
query.setLong(0, new Long(trannum));
query.setTimestamp(1, date);

tranlist=query.list();
}

Can you be more clear what do you mean by "attaching the Java object to the query"?
Please help me understand why that's happening...

thank you,
bhanu

>
+Pie Number of slices to send: Send
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

You can edit your post by using the button.
+Pie Number of slices to send: Send
If Hibernate doesn't know what type to associate with the query it'll return a list of Objects.
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2240 times.
Similar Threads
How do I assign variables with values from a list?
Need Help in Sorting Multiple columns!
Aggregate function in HQL
2 Dimmensional Array and asList
Help needed on following questions
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:49:05.