public String createDeleteQuery ( KunderaQuery kunderaQuery ) { EntityMetadata metadata = kunderaQuery . getEntityMetadata ( ) ; MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; CQLTranslator translator = new CQLTranslator ( ) ; String delete_query = translator . DELETE_QUERY ; String tableName = kunderaQuery . getEntityMetadata ( ) . getTableName ( ) ; delete_query = StringUtils . replace ( delete_query , CQLTranslator . COLUMN_FAMILY , translator . ensureCase ( new StringBuilder ( ) , tableName , false ) . toString ( ) ) ; StringBuilder builder = new StringBuilder ( delete_query ) ; builder . append ( CQLTranslator . ADD_WHERE_CLAUSE ) ; Class compoundKeyClass = metadata . getIdAttribute ( ) . getBindableJavaType ( ) ; EmbeddableType compoundKey = null ; String idColumn ; if ( metaModel . isEmbeddable ( compoundKeyClass ) ) { compoundKey = metaModel . embeddable ( compoundKeyClass ) ; idColumn = ( ( AbstractAttribute ) metadata . getIdAttribute ( ) ) . getJPAColumnName ( ) ; } else { idColumn = ( ( AbstractAttribute ) metadata . getIdAttribute ( ) ) . getJPAColumnName ( ) ; } onCondition ( metadata , metaModel , compoundKey , idColumn , builder , false , translator , false ) ; return builder . toString ( ) ; }
Create Delete query from a given JPA query .