Before you assume this is a duplicate, I'm aware of these answers (among others):
- Hibernate not creating Table automatically in spring boot using postgresql
- Unable to get Spring boot to automatically create database schema
- Spring Boot + Hibernate + Postgres - not creating tables
Still, auto-creating a table doesn't work!
I've used different versions of Hibernate
, Spring
, even implemented class JpaConfig
from JpaBaseConfiguration
, and adding deference properties from common application properties
Expected result:
Running hbm2ddl schema update
Actual result:
Running hbm2ddl schema export
I see org.hibernate.cfj.Configuration Iterator<Table> getTableMappings()
, but this method return emty list instead mapping class->table
Any help would be appreciated.
Application.yml:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/task-manager
username: postgres
password: password
schema: public
jpa:
generate-ddl: true
hibernate:
naming-strategy: ru.ssau.common.naming_strategy.CustomNamingStrategy
ddl-auto: create-drop
logging:
level:
org:
hibernate:
SQL: DEBUG
type:
descriptor:
sql:
BasicBinder: TRACE
Adding property driverClassName doesn't resolve it:
My entity:
@Entity(name = "simple_user")
public class User extends PersistentObject {
@Column(unique = true, nullable = false)
private String nickname;
@OneToOne
@JoinColumn(name = "user_account_id")
private UserAccount userAccount;
public User() {
}
public User(String nickname) {
this.nickname = nickname;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public UserAccount getUserAccount() {
return userAccount;
}
public void setUserAccount(UserAccount userAccount) {
this.userAccount = userAccount;
}
}
Hibernate's output from console:
HHH000412: Hibernate Core {4.3.11.Final}
HHH000206: hibernate.properties not found
HHH000021: Bytecode provider name : javassist
HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect
HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
HHH000397: Using ASTQueryTranslatorFactory
HHH000227: Running hbm2ddl schema export
HHH000230: Schema export complete