Oracle Char类型和Hibernate [英] Oracle Char type and Hibernate

查看:446
本文介绍了Oracle Char类型和Hibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个oracle表,它包含几个列的char(n)类型。我使用hibernate工具创建实体对象,并在String中使用此工具映射char类型。

但是,当我部署我的应用程序时,出现错误,因为Hibernate等待varchar2类型并不是字符类型:

  ARBOR.CMF中列CHG_WHO的列类型错误。发现:char,expected:varchar2(30 char)

必须使用什么样的java类型来映射char(n)在一个实体中的类型?



感谢。

解决方案

这里有一些有用的信息



基本上你需要让你的hibernate配置更加具体化,因为它假设一个默认的String映射到varchar2(30 )。


您可以尝试使用@Column(length = N)的数据库不可知注释(其中N是数据库中列的实际长度)。如果这不起作用,请尝试使用@Column(columnDefinition =char)方法。

I have a oracle table which contains char(n) type for several columns. I use hibernate tools to create entities objets and this tool map char type in String.

But when I deploy my application, I get an error because Hibernate wait a varchar2 type and not a char type:

Wrong column type in ARBOR.CMF for column CHG_WHO. Found: char, expected: varchar2(30 char)

What kind of java type must I use to map char(n) type in an entity ?

Thanks.

解决方案

There's some useful information here on this blog entry.

Essentially you need to make your hibernate configuration more specific, as it's assuming a default String mapping to varchar2(30).

You can try using the database-agnostic annotation of @Column(length=N) (where N is the actual length of your column in the database). If that doesn't work, try using the @Column(columnDefinition = "char") approach.

这篇关于Oracle Char类型和Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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