hibernate属性字符串长度问题

hibernate属性字符串长度问题

本文介绍了hibernate属性字符串长度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

 < property name =firstnametype =string > 
< column name =FIRSTNAMEnot-null =true/>
< / property>

< property name = descriptiontype =string>
< column name =DESCRIPTION/>
< / property>

我使用ANT脚本从映射文件生成数据库模式,并使用VARCHAR类型创建数据库字段我的问题是,我如何指定FIRSTNAME字段的最大长度是25,并且DESCRIPTION字段的最大长度是1000?我试过了

 < property name = description这个属性标记的长度属性(如下所示) type =stringlength =1000> 
< column name =DESCRIPTION/>
< / property>

有什么想法?

谢谢。 / p>

解决方案
 < property name =descriptiontype =string> 
< column name =descriptionlength =100/>
< / property>

您需要将其放置到列中。

I have an object mapped in hibernate like so:

<property name="firstname" type="string">
  <column name="FIRSTNAME" not-null="true" />
</property>

<property name=description" type="string">
  <column name="DESCRIPTION" />
</property>

I'm using an ANT script to generate the database schema from the mapping file and the db fields get created with type VARCHAR size 255.

My question is, how do I specify that the max length of the FIRSTNAME field is 25, and the max length of the DESCRIPTION field is 1000? I tried adding a length attribute to the property tag (as follows) but it didn't work:

<property name=description" type="string" length="1000">
  <column name="DESCRIPTION" />
</property>

Any ideas?

Thanks.

解决方案
        <property name="description" type="string">
            <column name="description" length="100" />
        </property>

you need to place it to the column.

这篇关于hibernate属性字符串长度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:49