hkais
hkais

Reputation: 338

JPA 2.1 custom naming strategy?

I have following table names with plural definition. But my classes are singular named. E.g. Table-Name: Employees Java-Classname: public class Employee {

Additionally our code convention defines the rule, that all member fields/variables have to have the prefix m_salery e.g. ColumnName: Salery Java-Fieldname: m_salery

Now my questions: What is the standard way in JPA 2.1 to define a default tablename strategy and a columnNmae strategy for the naming? If I need to define all java-fields and Entity-Annotations manually, I will go crazy.

Upvotes: 1

Views: 2308

Answers (1)

cmd
cmd

Reputation: 11841

JPA does not offer any globally applicable strategies for templating table/column names. Unfortunately, due to your code conventions, you are going to have to specify table names and column names manually using JPA annotations like @Table(name=...) and @Column(name=...).

It seems appropriate to avoid these code conventions here.

Code conventions are generally put in place to improve the readability of source code and make software maintenance easier. In this particular case, the conventions are not improving either case.

Upvotes: 2

Related Questions