hbm2ddl.auto 设置为 "UPDATE",但它试图在每次插入之前创建 table

hbm2ddl.auto is set to "UPDATE", but its trying to create table before every insertion

如果我错了请纠正我!
通常,如果 hbm2ddl.auto 设置为 "UPDATE",hibernate 会检查数据库中是否存在 table,如果不存在,它会创建 table 并推送数据,如果 table 存在它只是向 table.
添加数据 对于 hbm2ddl.auto = 更新,我观察到的是,在每次插入之前,hibernate 都试图创建 table。虽然 table 存在,但它会在日志中抛出异常,然后休眠就会知道 table.
的存在 这是正常行为吗?或者我遗漏了什么?

请在控制台中找到借助 log4j 生成的以下日志..

Hibernate: create table UsersCC (userID int4 not null, userDOB date, userEmail varchar(255), userPswd varchar(255), primary key (userID))
23:02:27,799  WARN ExceptionHandlerLoggedImpl:27 - GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:524)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:470)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.createTable(AbstractSchemaMigrator.java:273)
    at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:71)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:203)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:110)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
    at com.hibernate.Setup.SetupTest.main(SetupTest.java:19)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "userscc" already exists
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2310)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2023)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:217)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:421)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:318)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:310)
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
    ... 13 more
Hibernate: insert into UsersCC (userDOB, userEmail, userPswd, userID) values (?, ?, ?, ?)
23:02:27,998 TRACE BasicBinder:65 - binding parameter [1] as [DATE] - [Sun Jan 01 23:02:25 IST 2017]
23:02:27,999 TRACE BasicBinder:65 - binding parameter [2] as [VARCHAR] - [motogg@support.com]
23:02:28,000 TRACE BasicBinder:65 - binding parameter [3] as [VARCHAR] - [lenovo18]
23:02:28,004 TRACE BasicBinder:65 - binding parameter [4] as [INTEGER] - [101]
23:02:28,013  INFO pooling:230 - HHH10001008: Cleaning up connection pool [jdbc:postgresql://localhost:5432/campusCafeDb]

如果正常,那不是性能问题吗?

hbm2ddl.auto Validate : If the value is validate then hibernate only validates whether the table and columns are exist or not. If the table doesn’t exist then hibernate throws an exception. Validate is the default value for hbm2ddl.auto.

hbm2ddl.auto update : If the value is update then hibernate checks for the table and columns. If table doesn’t exist then it creates a new table and if a column doesn’t exist it creates new column for it.

这个 link 对所有值都有很好的解释。

http://www.onlinetutorialspoint.com/hibernate/hbm2ddl-auto-example-hibernate-xml-config.html

none 我猜是非官方值。我在 Whosebug 的某个地方找到了它,但我忘了在哪里。