I am facing the issue that Hibernate adds on default the prefix “HTE_” to all my assigned entities. My question is if there is a possible way to disable this or set another default prefix?
Example: @Entity @Table(name = “TEST_TABLE”)
the above table name results in HTE_TEST_TABLE when connecting to the Oracle database
I am using:
Java 19
Spring Boot version v3.0.1
Hibernate-core version 6.1.6.Final
Apache Maven version 3.8.6
Oracle Database 21c Express Edition for Windows x64
The HTE_ prefix is something that is prepended to temporary tables. These tables are created for certain multi-table mutation operations. Since Oracle has global temporary tables, these tables have to be created on startup upfront. You can create these tables yourself and then disable the automatic emitting of these create table DDLs, but you have to update to 6.2.0.CR1 for that, since the setting hibernate.hql.bulk_id_strategy.global_temporary.create_tables was only introduced as part of [HHH-15550] - Hibernate JIRA for 6.2.
Hi, Is it mandatory to create these HTE_ prefix tables separately or during server startup? what will be the impact if we don’t create these temp tables? Please advise.
You can create the tables along with the rest of your schema. If you do multi-table mutation operations and the tables are not there, you will see a SQL error.
Hi, I also noticed the HTE_ prefix tables being created in my project after upgrading to hibernate 6.2 but I don’t have any multi-table entities. Are these tables still needed when I don’t use @Inheritance(strategy = InheritanceType.JOINED)?
Hi @beikov, thanks for the quick answer. As suggested, I created a pull request with a test that fails if it detects that a HTE_* table was created. As you can see in my test, I simply created an Oracle test container and connected to it with a very simple entity.
Is this a bug? In my project we avoid @Inheritance(strategy = InheritanceType.JOINED), so would it make sense for us to disable the creation of the HTE_ tables via properties?
For your information, this is not a bug, but a consequence of the entity using a sequence generator with an allocationSize that is greater than 1, which makes it impossible to do multi-row inserts with a single SQL statement and hence requires the use of temporary tables.
In the jira ticket, you state that, since the entity has an id sequence with increment > 1, the HTE_ table is created, even if it is not a multi-table entitiy. This is my case. Now I would like to understand if I would use the HTE_ tables in practice.
Are these tables exclusively used in HQL inserts like the example you gave? insert into MySpecialEntity (attribute1) select e.data from OtherEntity e
Or are there other scenarios?
" I ran a quick test and was able to determine that the HTE_* temporary table creation in your case is triggered by the fact that your entity has a sequence-style generated id (@GeneratedValue(strategy = GenerationType.SEQUENCE)). This style of generators supports bulk-insertion, and this in-turn requires a multi-table insert strategy that uses temporary tables (on Oracle at least) as if there were multiple tables involved."
Where can I find some more information why GenerationType.SEQUENCE with allocationSize >1 requires "multi-table insert strategy ? Is this just some kind of optimization ? Or Am I missing something obvious ? In hibernate 5 HTE tables haven’t been required for such a case.
I’m not using Inheritance on my entities
I just have @SequenceGenerator with allocationSize >1
Is there any easy way to avoid HTE tables ? beside setting allocationSize to 1 ?
Our DBAs does’t like when hibernate creates tables and creating couple hundreds of table manually is not fun. Also I just want to know all the options.
Which hibernate property control insert strategy ?
I’m guessing that those are Insert strategies
Back to my main question:
Is there any easy way to avoid HTE tables ? beside setting allocationSize to 1 ?
Will Hibernate will fail when HTE tables are required but are missing on startup when “hibernate.ddl-auto=validate” ?