protected void onDeleteOrUpdate ( List results ) { if ( results != null ) { if ( ! kunderaQuery . isUpdateClause ( ) ) { // then case of delete for ( Object result : results ) { PersistenceCacheManager . addEntityToPersistenceCache ( result , persistenceDelegeator , PropertyAccessorHelper . getId ( result , this . getEntityMetadata ( ) ) ) ; persistenceDelegeator . remove ( result ) ; } } else { EntityMetadata entityMetadata = getEntityMetadata ( ) ; for ( Object result : results ) { PersistenceCacheManager . addEntityToPersistenceCache ( result , persistenceDelegeator , PropertyAccessorHelper . getId ( result , this . getEntityMetadata ( ) ) ) ; for ( UpdateClause c : kunderaQuery . getUpdateClauseQueue ( ) ) { String columnName = c . getProperty ( ) ; try { DefaultEntityType entityType = ( DefaultEntityType ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( entityMetadata . getPersistenceUnit ( ) ) . entity ( entityMetadata . getEntityClazz ( ) ) ; // That will always be attribute name. Attribute attribute = entityType . getAttribute ( columnName ) ; // TODO : catch column name. if ( c . getValue ( ) instanceof String ) { PropertyAccessorHelper . set ( result , ( Field ) attribute . getJavaMember ( ) , c . getValue ( ) . toString ( ) ) ; } else { PropertyAccessorHelper . set ( result , ( Field ) attribute . getJavaMember ( ) , c . getValue ( ) ) ; } persistenceDelegeator . merge ( result ) ; } catch ( IllegalArgumentException iax ) { log . error ( "Invalid column name: " + columnName + " for class : " + entityMetadata . getEntityClazz ( ) ) ; throw new QueryHandlerException ( "Error while executing query: " + iax ) ; } } } } } }
Performs delete or update based on query .