hibernate oracle char character 只查出一个

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:48   2007   0

public List queryTradeConfirmBusinFlag() { final String sql = "select C_BUSINFLAG, C_BUSINNAME from tbusinflag"; return (List) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Query query = session.createSQLQuery(sql); List<InitBusinFlag> list = query.list(); Iterator iter = list.iterator(); list = new ArrayList<InitBusinFlag>(); while(iter.hasNext()) { Object[] obj = (Object[])iter.next(); InitBusinFlag businFlag = new InitBusinFlag(); businFlag.setBusinFlag(obj[0].toString()); businFlag.setBusinName(obj[1].toString()); list.add(businFlag); } logger.debug("读取交易确认查询交易类型数据成功..."); return list; } }); }

C_BUSINFLAG 只能查出一个字符来

C_BUSINFLAG 在oracle数据库中是char(2)类型

改成final String sql = "select cast(C_BUSINFLAG as varchar2(2)), C_BUSINNAME from tbusinflag";

OK

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP