|
I was trying switch to ImprovedNamingStrategy. And I noticed that the column name in the create table for a @CollectionTable annotation is incorrect.
Config:
-
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
-
hibernate.hbm2ddl.auto=create-drop
Code example:
public enum Role {
BASIC, ADMIN;
}
@Entity(name = "User_Table")
public class User {
@ElementCollection(targetClass = Role.class)
@CollectionTable(name = "User_Role")
@Enumerated(EnumType.STRING)
@Column(name = "role")
private final Set<Role> roles = new HashSet<Role>(4);
}
For the above code snippet the following create statement is generated when ImprovedNamingStrategy is configured:
create table user_role (
user int8 not null,
role varchar(255)
)
Instead of the following what is generated when ImprovedNamingStrategy is not configured.
create table User_Role (
User_id int8 not null,
role varchar(255)
)
As a coincidence the generated column name "user" making the above create table statement invalid as user is a preserved keyword of PostgreSQL.
|