代码之家  ›  专栏  ›  技术社区  ›  CoderJammer

与DBEaver连接出现奇怪表

  •  0
  • CoderJammer  · 技术社区  · 10 月前

    我使用的是DBeaver 24.3.2、SpringBoot 3.4.1、Java 21.0.5、flyway 11.2.0。持久性库都是从spring数据继承而来的。

    我最近切换到SpringBoot 3.4,在做一个示例项目时,我注意到一个非常奇怪的行为。我有以下flyway和数据源配置:

    ########## DATASOURCE CONFIG ##############
    spring.datasource.url=jdbc:h2:file:D:/h2-dbms/rest-api/restapidb;AUTO_SERVER=TRUE;
    spring.datasource.username=sa
    spring.datasource.password=
    spring.datasource.driver-class-name=org.h2.Driver
    spring.h2.console.enabled=true
    spring.h2.console.settings.trace=false
    spring.h2.console.settings.web-allow-others=false
    spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
    
    ############ FLYWAY CONFIG ################
    spring.flyway.user=sa
    spring.flyway.password=
    spring.flyway.locations=classpath:migration
    

    我的 ddl 太简单了,甚至不值得写,在多对多关系中只有两个表。

    一切正常,但如果我用DBeaver连接到我的数据库,第一次一切似乎都很正常,第二次我看到其他两个与我类似的表(区别在于前缀 HTE_ 还有一列 RN_ 类型整数):

    enter image description here

    正如你所看到的表格 ROLES , USERS USERS_ROLES 是正确的,但我不知道是什么 HTE_USERS HTE_ROLES 意味着。

    另一件奇怪的事情是,HTE表是同一列加一列 RN_ (整数):

    enter image description here

    那是什么鬼东西??如果我使用http://localhost:8080/h2控制台上的web控制台打开数据库(始终使用文件模式,不在内存中),则不会发生任何事情。

    你有什么想法吗?

    注意:我显然不使用envers或其他审计框架。

    0 回复  |  直到 10 月前
        1
  •  0
  •   CoderJammer    10 月前

    如果您使用sequence,则Hibernate创建这些temps表时的正常行为不是错误 allocationSize 大于1。

    正如他们所说 分配大小 值等于1会导致性能不足,这就是默认值为50的原因。

    无论如何,从Hibernate 6.2.0 CR1开始,您可以使用以下命令禁用这些表的创建:

    hibernate.hql.bulk_id_strategy.global_temporary.create_tables=false
    

    但这似乎不是一种好的做法。

    更多信息 here .

    希望有帮助。

    推荐文章