#vulnerable code 
                             public <T> UpdateResults<T> update(T ent, UpdateOperations<T> ops) {
		MappedClass mc = mapr.getMappedClass(ent);
		Query<T> q = (Query<T>) createQuery(mc.getClazz());
		q.disableValidation().filter(Mapper.ID_KEY, getId(ent));
		
		if (mc.getFieldsAnnotatedWith(Version.class).size() > 0) {
			MappedField versionMF = mc.getFieldsAnnotatedWith(Version.class).get(0);
			Long oldVer = (Long)versionMF.getFieldValue(ent);
			q.filter(versionMF.getNameToStore(), oldVer);
			ops.set(versionMF.getNameToStore(), VersionHelper.nextValue(oldVer));
		}

		return update(q, ops);
	} 
                            #location 3 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             public <T> UpdateResults<T> update(T ent, UpdateOperations<T> ops) {
		if (ent instanceof Query)
			return update((Query<T>)ent, ops);
		
		MappedClass mc = mapr.getMappedClass(ent);
		Query<T> q = (Query<T>) createQuery(mc.getClazz());
		q.disableValidation().filter(Mapper.ID_KEY, getId(ent));
		
		if (mc.getFieldsAnnotatedWith(Version.class).size() > 0) {
			MappedField versionMF = mc.getFieldsAnnotatedWith(Version.class).get(0);
			Long oldVer = (Long)versionMF.getFieldValue(ent);
			q.filter(versionMF.getNameToStore(), oldVer);
			ops.set(versionMF.getNameToStore(), VersionHelper.nextValue(oldVer));
		}

		return update(q, ops);
	}