Aleksandra Zalcman
Aleksandra Zalcman

Reputation: 3498

How to make Hibernate reuse or recreate temporary tables during bulk updates

Hibernate handles UPDATE and DELETE operations on tables that are joined by the JOINED inheritance strategy by automatically creating temporary tables for storing the IDs of updated or deleted records (an excellent blog post on this is here: http://in.relation.to/Bloggers/MultitableBulkOperations).

In one transation, Hibernate creates a temporary table (named HT_mytable), inserts record IDs, deletes the entries from mytable with the stored IDs, and clears HT_mytable.

However, in my case it tries to create the table on every update, without first checking if it exists, by executing:

Hibernate: create global temporary table HT_child (record_id number(10,0) not null) 
on commit delete rows

So Oracle throws an exception:

ERROR spi.SqlExceptionHelper - ORA-00955: name is already used by an existing object

How to tell Hibernate not to create the table if it already exists?

Upvotes: 4

Views: 1532

Answers (1)

Christian Beikov
Christian Beikov

Reputation: 16420

As far as I know you can't. You could however drop the table by yourself as a workaround or create a custom bulk update strategy that implements it the way you'd like it to be.

Upvotes: 1

Related Questions