public PropertyMappingDefinition getPropMapByColumnName(String colName) { PropertyMappingDefinition md = propertyCacheByColName.get(colName); if (null != md) { return md; } else if (null != cfSuperMapDef) { return cfSuperMapDef.getPropMapByColumnName(colName); } else { return null; } }
@SuppressWarnings("unchecked") public boolean addColumnToCollection(CFMappingDef<?> cfMapDef, Object obj, String colName, byte[] colValue) { // if can parse, then at least adheres to formatting CollectionItemColName collColumnName; try { collColumnName = parseCollectionItemColName(colName); } catch (HectorObjectMapperException e) { return false; } // get property from mapping def - if not there, then isn't a collection // (but probably a problem elsewhere) PropertyMappingDefinition md = cfMapDef.getPropMapByColumnName(collColumnName.getPropertyName()); if (null == md) { return false; } Collection<Object> coll; try { coll = (Collection<Object>) reflectionHelper.invokeGetter(obj, md); } catch (HectorObjectMapperException e) { return false; } Object value = deserializeCollectionValue(colValue); coll.add(value); return true; }
PropertyMappingDefinition md = cfMapDefInstance.getPropMapByColumnName(colName); if (null != md && null != md.getPropDesc()) { if (!md.isCollectionType()) {
@Test public void testGetColFamMapDefByClass() { ClassCacheMgr cacheMgr = new ClassCacheMgr(); cacheMgr.initializeCacheForClass(MyTestBean.class); CFMappingDef<?> cfMapDef = cacheMgr.getCfMapDef(MyTestBean.class, false); assertNotNull(cfMapDef); assertEquals( "TestBeanColumnFamily", cfMapDef.getColFamName()); assertNotNull( "Column family not registered properly", cacheMgr.getCfMapDef("TestBeanColumnFamily", false)); assertEquals(MyTestBean.class, cfMapDef.getEffectiveClass()); assertEquals("did not find @Id properly", "baseId", cfMapDef.getKeyDef().getIdPropertyMap() .values().iterator().next() .getPropDesc().getName()); assertEquals("did not setup properties properly", ColorConverter.class, cfMapDef.getPropMapByColumnName("color").getConverter().getClass()); }