删除旧 DB2 数据库在查询结果上添加的填充
我有以下设置。
'Apps/Reports' <---------> 'DB2 Connect' <------------> 'Legacy DB2 on AS400'
`Hibernate` `native calls`
当应用程序检索数据时,如果长度小于列长度,则会用额外的空格填充。值得注意的是,运行查询时,如果未填充 WHERE
原因参数,则会自动填充额外的空格,以便查询将为已填充和未填充的参数检索相同的记录。
有没有办法(最好是在 IBM DB2 Connect 或连接字符串参数上)从结果集中删除多余的空格?
I have the following setup.
'Apps/Reports' <---------> 'DB2 Connect' <------------> 'Legacy DB2 on AS400'
`Hibernate` `native calls`
When data is retrieved from by the application, it will be padded with extra spaces if the length is less that the column length. Of note when running a query, if the WHERE
cause parameter is not padded, its automatically padded with extra spaces such that the query will retrieve the same records for a padded and non-padded parameter.
Is there a way (preferably on IBM DB2 Connect or connection string parameter) to remove extra whitespaces from a resultset?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以实现一个自动修剪字符串的休眠用户类型。 上有很好的例子
https://forum.hibernate.org/viewtopic.php?t= 928294
http://java.dzone.com/articles/annotating-custom-类型
http:// santescas.blogspot.de/2014/02/creando-un-usertype-de-hibernate-que-se.html
You could implement an hibernate UserType that automatically trim the strings. There are good exmaples on
https://forum.hibernate.org/viewtopic.php?t=928294
http://java.dzone.com/articles/annotating-custom-types
http://santescas.blogspot.de/2014/02/creando-un-usertype-de-hibernate-que-se.html
iSeries 中的列是否定义为 CHAR()?我假设是这样,因为这就是 CHAR() 的工作原理——它是固定字段长度,而不是可变字段长度(这就是 VARCHAR 的用途)。
Are the columns in the iSeries defined as CHAR()? I'm assuming so, because this is how CHAR() works -- it's a fixed field length, not a variable field length (that's what VARCHAR is for).