protected Query buildMtoNImplementorQuery ( Collection ids ) { String [ ] indFkCols = getFksToThisClass ( ) ; String [ ] indItemFkCols = getFksToItemClass ( ) ; FieldDescriptor [ ] pkFields = getOwnerClassDescriptor ( ) . getPkFields ( ) ; FieldDescriptor [ ] itemPkFields = getItemClassDescriptor ( ) . getPkFields ( ) ; String [ ] cols = new String [ indFkCols . length + indItemFkCols . length ] ; int [ ] jdbcTypes = new int [ indFkCols . length + indItemFkCols . length ] ; // concatenate the columns[] System . arraycopy ( indFkCols , 0 , cols , 0 , indFkCols . length ) ; System . arraycopy ( indItemFkCols , 0 , cols , indFkCols . length , indItemFkCols . length ) ; Criteria crit = buildPrefetchCriteria ( ids , indFkCols , indItemFkCols , itemPkFields ) ; // determine the jdbcTypes of the pks for ( int i = 0 ; i < pkFields . length ; i ++ ) { jdbcTypes [ i ] = pkFields [ i ] . getJdbcType ( ) . getType ( ) ; } for ( int i = 0 ; i < itemPkFields . length ; i ++ ) { jdbcTypes [ pkFields . length + i ] = itemPkFields [ i ] . getJdbcType ( ) . getType ( ) ; } ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria ( getItemClassDescriptor ( ) . getClassOfObject ( ) , cols , crit , false ) ; q . setIndirectionTable ( getCollectionDescriptor ( ) . getIndirectionTable ( ) ) ; q . setJdbcTypes ( jdbcTypes ) ; CollectionDescriptor cds = getCollectionDescriptor ( ) ; //check if collection must be ordered if ( ! cds . getOrderBy ( ) . isEmpty ( ) ) { Iterator iter = cds . getOrderBy ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { q . addOrderBy ( ( FieldHelper ) iter . next ( ) ) ; } } return q ; }
Build a query to read the mn - implementors