@Entity
class MyEntity {
}
hibernate.hbm2ddl.auto=update
Is it possible that hibernate will generate a CREATE unlogged TABLE
statement instead of CREATE TABLE
when the table for MyEntity
does not exist?
@Entity
class MyEntity {
}
hibernate.hbm2ddl.auto=update
Is it possible that hibernate will generate a CREATE unlogged TABLE
statement instead of CREATE TABLE
when the table for MyEntity
does not exist?
I think you can do this by subclassing the relevant Postgres dialect and overriding the getCreateTableString()
method as below.
public class CustomPostgresSQLDialect extends PostgresSQLxxDialect{
@Override
public String getCreateTableString() {
return "create unlogged table";
}
}
And obviously set this as your dialect:
<property name="hibernate.dialect" value="org.foo.CustomPostgresSQLDialect "/>
I think there's no param in @Entity
or @Table
to pass that kind of options to the DBMS. Found this feature request in hibernate's jira though, it covers your use case, maybe you want to vote for it.
Anyway you can try and add an auxiliary database object in the hibernate configuration to run ALTER TABLE MyEntity SET UNLOGGED
, it's the easiest way i can think of doing that DDL modification.