@SuppressWarnings("unchecked")
	public static <K,V> InverseHashView<K, V> inverseHashView(JdbmBase<K,V> base, String recordName){
    	SecondaryKeyExtractor<Integer,K,V> hashExtractor = new SecondaryKeyExtractor<Integer, K, V>() {
			long hashEqualsIdentityCounter=0;
			public Integer extractSecondaryKey(K key, V value) {
				int hashCode = value.hashCode();
				//little check to protect from hashCode not being overriden
				int identityHashCode = System.identityHashCode(value);
				if(hashCode == identityHashCode) 
					hashEqualsIdentityCounter++;
				else if(hashEqualsIdentityCounter>0) 
					hashEqualsIdentityCounter--;
				//fail if too many objects had hash equal to identityHashCode
				if(hashEqualsIdentityCounter>50) 
					throw new IllegalArgumentException("Object does not implement hashCode() correctly: "+value.getClass());
				return new Integer(hashCode);
			}
		};
		final SecondaryTreeMap<Integer, K, V> inverseMap = secondaryTreeMap(recordName,hashExtractor,ComparableComparator.INSTANCE,base); 
		
		return new InverseHashView<K, V>() {
			public K findKeyForValue(V val) {
				Iterable<K> keys = inverseMap.get(new Integer(val.hashCode()));
				if(keys == null) return null;
				for(K k:keys){
					if(val.equals(inverseMap.getPrimaryValue(k)))
						return k;
				}
				return null;
			}

			public Iterable<K> findKeysForValue(V val) {
				Iterable<K> keys = inverseMap.get(new Integer(val.hashCode()));
				List<K> ret = new ArrayList<K>();
				if(keys == null) return null;
				for(K k:keys){
					if(val.equals(inverseMap.getPrimaryValue(k)))
						ret.add(k);
				}
				return ret;
			}
		};
    }