简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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