@Column(name="DateOfBirth") private Date dateOfBirth;
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.
Advertisement
Answer
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.
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.