@ Override public List < Object > findByRelation ( String colName , Object colValue , Class entityClazz ) { // find by relational value ! EntityMetadata entityMetadata = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entityClazz ) ; MetamodelImpl metamodel = ( MetamodelImpl ) KunderaMetadataManager . getMetamodel ( kunderaMetadata , entityMetadata . getPersistenceUnit ( ) ) ; EntityType entityType = metamodel . entity ( entityMetadata . getEntityClazz ( ) ) ; Table schemaTable = tableAPI . getTable ( entityMetadata . getTableName ( ) ) ; Iterator < Row > rowsIter = null ; if ( schemaTable . getPrimaryKey ( ) . contains ( colName ) ) { PrimaryKey rowKey = schemaTable . createPrimaryKey ( ) ; NoSqlDBUtils . add ( schemaTable . getField ( colName ) , rowKey , colValue , colName ) ; rowsIter = tableAPI . tableIterator ( rowKey , null , null ) ; } else { Index index = schemaTable . getIndex ( colName ) ; IndexKey indexKey = index . createIndexKey ( ) ; NoSqlDBUtils . add ( schemaTable . getField ( colName ) , indexKey , colValue , colName ) ; rowsIter = tableAPI . tableIterator ( indexKey , null , null ) ; } try { Map < String , Object > relationMap = initialize ( entityMetadata ) ; return scrollAndPopulate ( null , entityMetadata , metamodel , schemaTable , rowsIter , relationMap , null ) ; } catch ( Exception e ) { log . error ( "Error while finding data for Key " + colName + ", Caused By :" + e + "." ) ; throw new PersistenceException ( e ) ; } }
Find by relational column name and value .