简体   繁体   English

在 Hibernate 中使用更新但仍在创建表

[英]In Hibernate using update but still going for a create table

Using Hibernate in my project.在我的项目中使用 Hibernate。 I am getting create table queries at my logs,我在我的日志中获取create table查询,

But I am using a HBM2DDL_AUTO="update"但我使用的是HBM2DDL_AUTO="update"

What else could had been missed?还有什么可以错过的?

PS: I get these logs only when the tables are already present at runtime. PS:只有在运行时表已经存在时,我才会得到这些日志。 If tables not present, it obviously runs smooth.如果表不存在,它显然运行顺利。

Here are the properties这里是属性

Properties settings = new Properties();
settings.put(Environment.DRIVER, "org.postgresql.Driver");
settings.put(Environment.URL, "jdbc:postgresql://" + jdbc_host + ":5432/" + jdbc_database + "?prepareThreshold=0");
settings.put(Environment.USER, jdbc_user);
settings.put(Environment.PASS, jdbc_password);
settings.put(Environment.DIALECT, "org.hibernate.dialect.PostgreSQLDialect");
settings.put(Environment.SHOW_SQL, "true");
settings.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
settings.put(Environment.HBM2DDL_AUTO, "update");

Error Logs:错误日志:

[INFO ]: org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
[INFO ]: org.hibernate.type.BasicTypeRegistry - HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@3add81c4
[WARN ]: org.hibernate.boot.internal.InFlightMetadataCollectorImpl - HHH000069: Duplicate generator name wca_seq_generator
[WARN ]: org.hibernate.boot.internal.InFlightMetadataCollectorImpl - HHH000069: Duplicate generator name wca_seq_generator
[WARN ]: org.hibernate.boot.internal.InFlightMetadataCollectorImpl - HHH000069: Duplicate generator name wca_seq_generator
[INFO ]: org.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@59696551] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
[WARN ]: org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl - GenerationTarget encountered exception accepting command : Error executing DDL "create table WCA_MESSAGE_AUDIT (id int8 not null, createts times
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table WCA_MESSAGE_AUDIT (id int8 not null, create
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504)

I have not worked postgresql in java but I've worked with MySQL.我没有在 java 中工作过 postgresql,但我使用过 MySQL。 And Whenever' I need to create the table using hibernate then I mention the follow feature in application.properties and it allow to create the table.每当我需要使用 hibernate 创建表时,我会在 application.properties 中提到以下功能,它允许创建表。 please once go for it and if it still doesn't work please inform me.请给它一次 go 如果它仍然不起作用,请通知我。 Put it in proprerties.把它放在属性中。

spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM