/** * Convenience method that takes a result set that contains a discriminator column and returns the * class name that it represents. * * @param discrimMapping Mapping for the discriminator column * @param dismd Metadata for the discriminator * @param rs The result set * @param ec execution context * @return The class name for the object represented in the current row */ public static String getClassNameFromDiscriminatorResultSetRow( JavaTypeMapping discrimMapping, DiscriminatorMetaData dismd, ResultSet rs, ExecutionContext ec) { String rowClassName = null; if (discrimMapping != null && dismd.getStrategy() != DiscriminatorStrategy.NONE) { try { String discriminatorColName = discrimMapping.getDatastoreMapping(0).getColumn().getIdentifier().getIdentifierName(); String discriminatorValue = rs.getString(discriminatorColName); rowClassName = ec.getMetaDataManager().getClassNameFromDiscriminatorValue(discriminatorValue, dismd); } catch (SQLException e) { // discriminator column doesn't exist with this name } } return rowClassName; }
private static void addColumnsToScanForEmbeddedMember( Scan scan, List<AbstractMemberMetaData> embMmds, Table table, ExecutionContext ec) { AbstractMemberMetaData lastMmd = embMmds.get(embMmds.size() - 1); ClassLoaderResolver clr = ec.getClassLoaderResolver(); AbstractClassMetaData embCmd = ec.getMetaDataManager().getMetaDataForClass(lastMmd.getTypeName(), clr); int[] embMmdPosns = embCmd.getAllMemberPositions(); for (int i = 0; i < embMmdPosns.length; i++) { AbstractMemberMetaData embMmd = embCmd.getMetaDataForManagedMemberAtAbsolutePosition(i); List<AbstractMemberMetaData> subEmbMmds = new ArrayList<AbstractMemberMetaData>(embMmds); subEmbMmds.add(embMmd); RelationType relationType = embMmd.getRelationType(clr); MemberColumnMapping mapping = table.getMemberColumnMappingForEmbeddedMember(subEmbMmds); if (RelationType.isRelationSingleValued(relationType)) { addColumnsToScanForEmbeddedMember(scan, subEmbMmds, table, ec); } else { String familyName = HBaseUtils.getFamilyNameForColumn(mapping.getColumn(0)); String qualifName = HBaseUtils.getQualifierNameForColumn(mapping.getColumn(0)); scan.addColumn(familyName.getBytes(), qualifName.getBytes()); } } }