Hibernate @formula is not supportinng Cast() as int for teradata database

吃可爱长大的小学妹 提交于 2019-11-27 04:52:57

问题


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 .


回答1:


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.



来源:https://stackoverflow.com/questions/25679818/hibernate-formula-is-not-supportinng-cast-as-int-for-teradata-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!