public String createUpdateQuery ( KunderaQuery kunderaQuery ) { EntityMetadata metadata = kunderaQuery . getEntityMetadata ( ) ; MetamodelImpl metaModel = ( MetamodelImpl ) kunderaMetadata . getApplicationMetadata ( ) . getMetamodel ( metadata . getPersistenceUnit ( ) ) ; CQLTranslator translator = new CQLTranslator ( ) ; String update_Query = translator . UPDATE_QUERY ; String tableName = metadata . getTableName ( ) ; update_Query = StringUtils . replace ( update_Query , CQLTranslator . COLUMN_FAMILY , translator . ensureCase ( new StringBuilder ( ) , tableName , false ) . toString ( ) ) ; StringBuilder builder = new StringBuilder ( update_Query ) ; Object ttlColumns = ( ( CassandraClientBase ) persistenceDelegeator . getClient ( metadata ) ) . getTtlValues ( ) . get ( metadata . getTableName ( ) ) ; if ( ( ttlColumns != null && ttlColumns instanceof Integer ) || this . ttl != null ) { int ttl = this . ttl != null ? this . ttl : ( ( Integer ) ttlColumns ) . intValue ( ) ; if ( ttl != 0 ) { builder . append ( " USING TTL " ) ; builder . append ( ttl ) ; builder . append ( " " ) ; } } builder . append ( CQLTranslator . ADD_SET_CLAUSE ) ; for ( UpdateClause updateClause : kunderaQuery . getUpdateClauseQueue ( ) ) { String property = updateClause . getProperty ( ) ; String jpaColumnName = getColumnName ( metadata , property ) ; Object value = updateClause . getValue ( ) ; translator . buildSetClause ( metadata , builder , jpaColumnName , value ) ; } builder . delete ( builder . lastIndexOf ( CQLTranslator . COMMA_STR ) , builder . length ( ) ) ; 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 Update CQL query from a given JPA query .