如何告诉JPA优先的DataType [英] How to Tell JPA the prefered DataType

查看:364
本文介绍了如何告诉JPA优先的DataType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用JPA(EclipseLink)来创建表,String类型会产生一个varchar2(255)。我如何告诉JPA(通过注释)创建一个varchar2(20)属性。



如果我有一个列表JPA创建一个BLOB(4000),但我想要一个varchar2(我的序列化对象的字符串很短)



这怎么可能?

解决方案

您需要使用@Column注释的columnDefinition属性。

  @Column(columnDefinition =varchar2(20))
pre>

If I use JPA (EclipseLink) to create tables a String type results in a varchar2(255). How could I tell JPA (via Annotation) to create a varchar2(20) attribute.

If I have a List JPA creates a BLOB(4000) but I would like a varchar2 (my serialized object's string is short)

How is this possible? Do I have to do it by hand?

解决方案

You need to use the columnDefinition property of the @Column annotation. i.e.

@Column(columnDefinition="varchar2(20)")

这篇关于如何告诉JPA优先的DataType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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