开发者

EJB3NamingStrategy vs ImprovedNamingStrategy Foreign Key Naming

开发者 https://www.devze.com 2023-04-11 17:24 出处:网络
My naming strategy in hibernate was the default one : EJB3Naming开发者_如何学CStrategy. So the field and table names was in camelcase. I switched it to ImprovedNamingStrategy to have snakecase.

My naming strategy in hibernate was the default one : EJB3Naming开发者_如何学CStrategy. So the field and table names was in camelcase. I switched it to ImprovedNamingStrategy to have snakecase.

But my foreign keys doesn't include the primary key name of the referenced entity in the name.

Example:

table1: id name

With EJB3NamingStrategy the table2 fields will be:

table2: id table1_id

but with ImprovedNamingStrategy the table2 fields will be: table2: id table1

Is there a way to have _id with the ImprovedNamingStrategy. I don't understand why hibernate behave differently because the logicalCollectionColumnName method in both strategy are identical.


Extend the improvedNamingStrategy and customize, maybe the initial implementation of the ImprovedNamingStrategy got this wrong and then they couldn't fix it as it would break backward compatability.


This issue is resolved in spring boot 1.2.7.RELEASE. Reference of this thread is also specified in the documentation of the jpa hibernate package. Class signature as follows:

package org.springframework.boot.orm.jpa.hibernate;

public class SpringNamingStrategy extends ImprovedNamingStrategy {}
0

精彩评论

暂无评论...
验证码 换一张
取 消