public Query getQueryImplementation ( String jpaQuery , PersistenceDelegator persistenceDelegator , Class mappedClass , boolean isNative , final KunderaMetadata kunderaMetadata ) { if ( jpaQuery == null ) { throw new QueryHandlerException ( "Query String should not be null " ) ; } if ( jpaQuery . trim ( ) . endsWith ( Constants . SEMI_COLON ) ) { throw new QueryHandlerException ( "unexpected char: ';' in query [ " + jpaQuery + " ]" ) ; } KunderaQuery kunderaQuery = null ; ApplicationMetadata appMetadata = kunderaMetadata . getApplicationMetadata ( ) ; String mappedQuery = appMetadata . getQuery ( jpaQuery ) ; isNative = mappedQuery != null ? appMetadata . isNative ( jpaQuery ) : isNative ; EntityMetadata m = null ; // In case of named native query if ( ! isNative ) { kunderaQuery = new KunderaQuery ( mappedQuery != null ? mappedQuery : jpaQuery , kunderaMetadata ) ; KunderaQueryParser parser = new KunderaQueryParser ( kunderaQuery ) ; parser . parse ( ) ; kunderaQuery . postParsingInit ( ) ; m = kunderaQuery . getEntityMetadata ( ) ; } else { // Means if it is a namedNativeQuery. if ( appMetadata . isNative ( jpaQuery ) ) { mappedClass = appMetadata . getMappedClass ( jpaQuery ) ; } kunderaQuery = new KunderaQuery ( jpaQuery , kunderaMetadata ) ; kunderaQuery . isNativeQuery = true ; m = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , mappedClass ) ; Field entityClazzField = null ; try { entityClazzField = kunderaQuery . getClass ( ) . getDeclaredField ( "entityClass" ) ; if ( entityClazzField != null && ! entityClazzField . isAccessible ( ) ) { entityClazzField . setAccessible ( true ) ; } entityClazzField . set ( kunderaQuery , mappedClass ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) ) ; throw new QueryHandlerException ( e ) ; } } Query query = null ; try { query = getQuery ( jpaQuery , persistenceDelegator , m , kunderaQuery , kunderaMetadata ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) ) ; throw new QueryHandlerException ( e ) ; } return query ; }
Gets the query implementation .