• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue with String types when hibernate returns list of Object arrays

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're probably not attaching the Java object to the query, but without seeing the query, it's tough to help.
 
Bhanu S Chatta
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

>
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If Hibernate doesn't know what type to associate with the query it'll return a list of Objects.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic