Reputation: 1276
I'm trying to find out what column name JPA uses when there's no explicit name set.
Example:
@Entity
public class TestType {
private Boolean active;
private Character testTypeCode;
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
@Id
public Character getTestTypeCode() {
return testTypeCode;
}
public void setTestTypeCode(Character testTypeCode) {
this.testTypeCode = testTypeCode;
}
}
What name will be used for the primary key column, which column name will be used for the property "active" and what table name will be used. I'm looking for the specification of what names JPA uses by default.
Upvotes: 0
Views: 488
Reputation: 19002
It is the chapter "2.13 Naming of Database Objects" that specifies that (JPA 2.0 spec).
This specification requires the following with regard to the interpretation of the names referencing database objects. These names include the names of tables, columns, and other database elements. Such names also include names that result from defaulting (e.g., a table name that is defaulted from an entity name or a column name that is defaulted from a field or property name).
In you example, the table name would be TestType
, the ID column name testTypeCode
and the active column would the called the same. Please also note, that in the SQL Standard all column and table names are case insensitive, although there are some counterexamples (e.g MySQL on Unix: the table names are case sensitive).
Upvotes: 1