冬眠列名的问题 [英] hibernate column name issues
问题描述
@Column(name="DateOfBirth")
private Date dateOfBirth;
我特别需要上述code创建一个名为列出生日期,而不是休眠给了我一个名为列DATE_OF_BIRTH。我该如何改变呢?是否有一个web.xml的财产?我碰到DefaultNamingStrategy和ImprovedNamingStrategy,但不知道如何指定一个或另一个。
I specifically need the above code to create a column named "DateOfBirth," instead Hibernate gives me a column named date_of_birth. How can I change this? Is there a web.xml property? I came across DefaultNamingStrategy and ImprovedNamingStrategy, but not sure how to specify one or the other.
推荐答案
下面是一个可能的解决方法:如果你将其命名为出生日期
在DB栏将被命名为喜欢这一点,但属性名称应该是相同的。
Here is a possible workaround: if you name it dateofbirth
the column in the DB would be named like that, but the attribute name should be the same.
休眠取驼峰格式创建/读取数据库列。
Hibernate takes the camel case format to create/read database columns.
我以前有这个问题。我曾与那里有列名employeename没有空间,employeerole,departmentlocation遗留列。我恨它,因为我所有的bean的属性必须是没有骆驼。
I've had this problem before. I worked with a legacy columns where there was no space in the column names "employeename", "employeerole", "departmentlocation". I hate it because all my beans properties had to be without camel case.
分隔的数据库列_将被用于正确驼峰像你刚才看到的。
Database columns separated by "_" will be used to properly camelCase as you have just seen.
这篇关于冬眠列名的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!