-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Exception when String property map character column in db2
PostPosted: Sat Sep 02, 2006 7:30 am 
Newbie

Joined: Sat Sep 02, 2006 6:29 am
Posts: 2
I am using annotion to map the entity to table, but meet this problem. Exception "argument type mismatch" rised when a String property map a character column in db2 by using org.hibernate.transform.ResultTransformer, here is the code which will rise exception:
String sql = "select id, name from table1";
SQLQuery sq = session.createSQLQuery(sql);
sq.setResultTransformer(Transformers.aliasToBean(XXVO.class));
return sq.list();

The id's data type is character(length 26), the name's is varchar, and I have String property "id" and "name" in entity XXVO. In the code above, actually Hibernate use org.hibernate.transform.AliasToBeanResultTransformer to map the tuple get from ResultSet to property of entity XXVO. I found that the mapping of "name" is ok, but for the mapping of "id", I see that the tuple is a java.lang.Character instance, not String. And the value of tuple is the first char of the real value of "id". So that's why the exception arise.

But when I was using SQLQuery.addEntity instead of the org.hibernate.transform.ResultTransformer, the mapping between property and column is ok, here is the code which do not rise exception:
String sql = "select * from table1";
SQLQuery sq = session.createSQLQuery(sql);
sq.addEntity(XXVO.class);
return sq.list();


Is it the bug of Hibernate? Thanks for help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.