hibernate 怎么设置数据类型的长度
我的表里有几个char类型的字段,当我保存SESSION后,hibernate生成的SQL是
exec sp_executesql N 'update test.dbo.student set name=@P1, sex=@P2, age=@P3, nationality=@P4, address=@P5, phonenumber=@P6 where id=@P7 ', N '@P1 nvarchar(4000) ,@P2 nvarchar(4000) ,@P3 int ,@P4 nvarchar(4000) ,@P5 nvarchar(4000) ,@P6 bigint ,@P7 int ', N 'wu ', NULL, NULL, N 'wuming ', NULL, NULL, 1
他把所有的char字段都换成了nvarchar(4000),我在数据库里执行好像是死的,我把nvarchar(4000)改成nvarchar(10)就可以执行,请问我怎么在hibernate里设置成需要的类型呢,这是我的配置文件
<class name= "com.hanbase.hibernate.Student " table= "student " schema= "dbo " catalog= "test ">
<id name= "id " type= "java.lang.Integer ">
<column name= "id " />
<generator class= "assigned " />
</id>
<property name= "name " type= "java.lang.String ">
<column name= "name " length= "10 " />
</property>
<property name= "sex " type= "java.lang.String ">
<column name= "sex " length= "10 " />
</property>
<property name= "age " type= "java.lang.Integer ">
<column name= "age " />
</property>
<property name= "nationality " type= "java.lang.String ">
<column name= "nationality " length= "10 " />
</property>
<property name= "address " type= "java.lang.String ">
<column name= "address " length= "50 " />
</property>
<property name= "phonenumber " type= "java.lang.Long ">
<column name= "phonenumber " />
</property>
</class>
[解决办法]
Up
[解决办法]
用verchar不行么? 为什么要用char呢> ?