对于Teradata数据库,Hibernate @formula不支持将Cast()作为int [英] Hibernate @formula is not supportinng Cast() as int for teradata database
问题描述
我正在使用
@Formula(cast(item_code as \int \))
将字符串
列转换为 int
但 hibernate
正在将查询生成为
和cast(this_.item_code as this。。int)=?
如何摆脱别名
$ b
> @Formula(cast(item_code asint))
和 @Formula(cast(item_code as int))
但仍然是相同的错误。我如何将字符串
转换为 int
?
预先感谢。
给你。我为我的数据库扩展了hibernate Dialect类。
public class Oracle10gDialectExtended extends Oracle10gDialect {
public Oracle10gDialectExtended (){
super();
/ *类型为cast:* /
registerKeyword(int);
//添加更多保留字,因为您需要
code>
用这个新类设置'hibernate.dialect'属性。现在你的@Formula会起作用。
I am using
@Formula("cast(item_code as \"int\")")
to cast a String
column to int
but hibernate
is generating the query as
and cast(this_.item_code as this_."int")=?
How do i get rid of the alias
in front of int
?
I tried :
@Formula("cast(item_code as "int")")
and @Formula("cast(item_code as int)")
but still the same error . How do i cast the String
to int
?
Thanks in advance .
I have resolved an issue similar to yours. I extended the hibernate Dialect class for my database.
public class Oracle10gDialectExtended extends Oracle10gDialect {
public Oracle10gDialectExtended() {
super();
/* types for cast: */
registerKeyword("int");
// add more reserved words as you need
}
}
Set 'hibernate.dialect' property with this new class. Now your @Formula will work.
这篇关于对于Teradata数据库,Hibernate @formula不支持将Cast()作为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!