对于Teradata数据库,Hibernate @formula不支持将Cast()作为int [英] Hibernate @formula is not supportinng Cast() as int for teradata database

查看:215
本文介绍了对于Teradata数据库,Hibernate @formula不支持将Cast()作为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

  @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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆