java - Hibernate Multi-table Bulk Operations always try to create the temporary table -


i have entities using join-inheritance , i'm doing bulk operations on them. explained in multi-table bulk operations hibernate uses temporary table execute bulk operations.

as understand temporary tables data in them temporary (deleted @ end of transaction or session) table permanent. see hibernate tries create temporary table every time such query executed. in case more 35.000 times per hour. create table statement fails every time, because table name exists. unnecessary , hurts performance, dbas not happy...

is there way hibernate remembers created temporary table?

if not, there workarounds? idea use single-table-inheritance instead avoid using temporary tables completely.

hibernate version 4.2.8, db oracle 11g.

i think bug in temporarytablebulkidstrategy, because when using oracle8idialect says temporary tables shouldn't deleted:

@override public boolean droptemporarytableafteruse() {     return false; } 

but check made when deleting table:

protected void releasetemptable(queryable persister, sessionimplementor session) {     if ( session.getfactory().getdialect().droptemporarytableafteruse() ) {         temporarytabledropwork work = new temporarytabledropwork( persister, session );         if ( shouldisolatetemporarytableddl( session ) ) {             session.gettransactioncoordinator()                     .gettransaction()                     .createisolationdelegate()                     .delegatework( work, shouldtransactisolatedtemporarytableddl( session ) );         }         else {             final connection connection = session.gettransactioncoordinator()                     .getjdbccoordinator()                     .getlogicalconnection()                     .getconnection();             work.execute( connection );             session.gettransactioncoordinator()                     .getjdbccoordinator()                     .afterstatementexecution();         }     }     else {         // @ least cleanup data :)         preparedstatement ps = null;         try {             final string sql = "delete " + persister.gettemporaryidtablename();             ps = session.gettransactioncoordinator().getjdbccoordinator().getstatementpreparer().preparestatement( sql, false );             session.gettransactioncoordinator().getjdbccoordinator().getresultsetreturn().executeupdate( ps );         }         catch( throwable t ) {             log.unabletocleanuptemporaryidtable(t);         }         {             if ( ps != null ) {                 try {                     session.gettransactioncoordinator().getjdbccoordinator().release( ps );                 }                 catch( throwable ignore ) {                     // ignore                 }             }         }     } } 

but when creating table:

protected void createtemptable(queryable persister, sessionimplementor session) {     // don't know codes required adequately decipher returned jdbc exceptions here.     // allow failure eaten , subsequent insert-selects/deletes should fail     temporarytablecreationwork work = new temporarytablecreationwork( persister );     if ( shouldisolatetemporarytableddl( session ) ) {         session.gettransactioncoordinator()                 .gettransaction()                 .createisolationdelegate()                 .delegatework( work, shouldtransactisolatedtemporarytableddl( session ) );     }     else {         final connection connection = session.gettransactioncoordinator()                 .getjdbccoordinator()                 .getlogicalconnection()                 .getconnection();         work.execute( connection );         session.gettransactioncoordinator()                 .getjdbccoordinator()                 .afterstatementexecution();     } } 

as workaround, extend oracle dialect , override droptemporarytableafteruse method return false.

i filled hhh-9744 issue this.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -