private void initEntityClass ( ) { if ( from == null ) { throw new JPQLParseException ( "Bad query format FROM clause is mandatory for SELECT queries" ) ; } String fromArray [ ] = from . split ( " " ) ; if ( ! this . isDeleteUpdate ) { if ( fromArray . length == 3 && fromArray [ 1 ] . equalsIgnoreCase ( "as" ) ) { fromArray = new String [ ] { fromArray [ 0 ] , fromArray [ 2 ] } ; } if ( fromArray . length != 2 ) { throw new JPQLParseException ( "Bad query format: " + from + ". Identification variable is mandatory in FROM clause for SELECT queries" ) ; } // TODO StringTokenizer tokenizer = new StringTokenizer ( result [ 0 ] , "," ) ; while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; if ( ! StringUtils . containsAny ( fromArray [ 1 ] + "." , token ) ) { throw new QueryHandlerException ( "bad query format with invalid alias:" + token ) ; } } } this . entityName = fromArray [ 0 ] ; if ( fromArray . length == 2 ) this . entityAlias = fromArray [ 1 ] ; persistenceUnit = kunderaMetadata . getApplicationMetadata ( ) . getMappedPersistenceUnit ( entityName ) ; // Get specific metamodel. MetamodelImpl model = getMetamodel ( persistenceUnit ) ; if ( model != null ) { entityClass = model . getEntityClass ( entityName ) ; } if ( null == entityClass ) { logger . error ( "No entity {} found, please verify it is properly annotated with @Entity and not a mapped Super class" , entityName ) ; throw new QueryHandlerException ( "No entity found by the name: " + entityName ) ; } EntityMetadata metadata = model . getEntityMetadata ( entityClass ) ; if ( metadata != null && ! metadata . isIndexable ( ) ) { throw new QueryHandlerException ( entityClass + " is not indexed. Not possible to run a query on it." + " Check whether it was properly annotated for indexing." ) ; } }
Inits the entity class .