我讀了一些類似的查詢,但我的問題是「一點點不同」。休眠不創建表 - 一些轉換器
我有實體一樣
@Entity
@Table(name = "commission_template")
public class CommmissionTemplate {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;
private Double min;
private Double max;
private Double value;
private boolean active;
@Convert(converter = LocalDateToSqlConverter.class)
private LocalDate start;
@Convert(converter = LocalDateToSqlConverter.class)
private LocalDate end;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "commission_template_commission_type",
joinColumns = {@JoinColumn(name = "commission_template_id", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "type_id", referencedColumnName = "name")}
)
private CommissionType type;
// getters/setters etc.
}
在
persistence.xml
而配置方面一樣
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="${db.dialect}"/>
然後當我在日誌中開始應用Ÿ我已經:
Hibernate: create table commission_template (id int8 not null, active boolean not null, end timestamp, max float8, min float8, start timestamp, value float8, primary key (id))
Hibernate: create table commission_template_commission_type (type_id varchar(255), commission_template_id int8 not null, primary key (commission_template_id))
在這裏我們有魔力,因爲Hibernate不會創建表commission_template
。 pgAdmin告訴我「沒有這樣的桌子」。最好的事情是,當我關閉應用程序和Hibernate調用drop時,他們記錄下他們丟棄的commission_template
表。
我試圖改變表的名字,我把它設置爲prowizje_szablony
...
Caused by: org.postgresql.util.PSQLException: ERROR: relation "prowizje_szablony" does not exist
Pozycja: 273
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2077)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1810)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:498)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82)
... 77 more
任何想法,建議或提示?
//編輯:國際海事組織,問題是在轉換器的地方,休眠不能處理與他們的表。
//解決方法:手動創建該表通過:
CREATE TABLE commissiontemplate
(
id bigint NOT NULL,
active boolean,
start timestamp without time zone,
"end" timestamp without time zone,
min double precision,
max double precision,
value double precision,
CONSTRAINT id PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE commissiontemplate
OWNER TO koziolek;
與默認名稱(我知道指甲油是相當不錯的語言,你可以調用表chrząszcz
,但請...不是IT)和變化DDL到validate
不是很好,因爲我們需要額外的工具來覆蓋架構更新,但作品...