Hibernate实体字段camelcase,数据库下划线 [英] Hibernate entity fields camelcase, database underscore
问题描述
我有下划线的数据库字段。我在camelcase中有实体字段。
是否有某种东西,或许是我可以使用的默认实体列名称注释,与camelcase等价的注释?
>例如,我有一个这样的实体:
@Entity
public class AuthorisationEntity {
@Column(name =non_recoverable)
private BigDecimal nonRecoverable;
@Column(name =supplier_recoverable)
private BigDecimal supplierRecoverable;
@Column(name =refund_amount)
私人BigDecimal refundAmount;
}
我梦寐以求:
@Entity
@DatabaseIsUnderscoreAndThisAnnotationConvertsThemToCamelCaseByDefault
public class AuthorisationEntity {
private BigDecimal nonRecoverable;
private BigDecimal supplierRecoverable;
私人BigDecimal refundAmount;
使用hibernate的命名策略。这种命名策略类描述了如何为给定的java名称生成数据库名称。
请参阅:
非常好的oracle命名策略 - 它将骆驼转换为下划线约定,等等
I have database fields in underscore. I have entity fields in camelcase. I can't change either of those.
Is there something, maybe a class level annotation I can use to default entity column name annotations to the camelcase equivalent?
for example, I have an entity like this:
@Entity
public class AuthorisationEntity {
@Column(name = "non_recoverable")
private BigDecimal nonRecoverable;
@Column(name = "supplier_recoverable")
private BigDecimal supplierRecoverable;
@Column(name = "refund_amount")
private BigDecimal refundAmount;
}
I dream of this:
@Entity
@DatabaseIsUnderscoreAndThisAnnotationConvertsThemToCamelCaseByDefault
public class AuthorisationEntity {
private BigDecimal nonRecoverable;
private BigDecimal supplierRecoverable;
private BigDecimal refundAmount;
}
You can use hibernate's naming strategy. Such naming strategy class describes how to generate database names for given java names.
See:
very good oracle naming strategy - it converts camel to underscore convention, and much more
这篇关于Hibernate实体字段camelcase,数据库下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!