public List < Object > findByRelation ( String colName , Object colValue , Class entityClazz ) { EntityMetadata m = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entityClazz ) ; // you got column name and column value. DBCollection dbCollection = mongoDb . getCollection ( m . getTableName ( ) ) ; BasicDBObject query = new BasicDBObject ( ) ; query . put ( colName , MongoDBUtils . populateValue ( colValue , colValue . getClass ( ) ) ) ; KunderaCoreUtils . printQuery ( "Find by relation:" + query , showQuery ) ; DBCursor cursor = dbCollection . find ( query ) ; DBObject fetchedDocument = null ; List < Object > results = new ArrayList < Object > ( ) ; while ( cursor . hasNext ( ) ) { fetchedDocument = cursor . next ( ) ; populateEntity ( m , results , fetchedDocument ) ; } return results . isEmpty ( ) ? null : results ; }
Method to find entity for given association name and association value .