Program: 176178
Project: 176178
Buggy source:
private void onPersist(EntityMetadata entityMetadata,Object entity,Object id,List<RelationHolder> rlHolders,Object connection){
  AttributeWrapper wrapper=wrap(entityMetadata,entity);
  if (rlHolders != null) {
    for (    RelationHolder relation : rlHolders) {
      String name=relation.getRelationName();
      Object value=relation.getRelationValue();
      byte[] valueInBytes=PropertyAccessorHelper.getBytes(value);
      byte[] nameInBytes=getEncodedBytes(name);
      String valueAsStr=PropertyAccessorHelper.getString(value);
      wrapper.addColumn(nameInBytes,valueInBytes);
      wrapper.addIndex(getHashKey(entityMetadata.getTableName(),name),getDouble(valueAsStr));
      wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(name,valueAsStr)),getDouble(valueAsStr));
    }
  }
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
  EntityType entityType=metaModel.entity(entityMetadata.getEntityClazz());
  String discrColumn=((AbstractManagedType)entityType).getDiscriminatorColumn();
  String discrValue=((AbstractManagedType)entityType).getDiscriminatorValue();
  if (discrColumn != null && discrValue != null) {
    byte[] valueInBytes=PropertyAccessorHelper.getBytes(discrValue);
    byte[] nameInBytes=getEncodedBytes(discrColumn);
    wrapper.addColumn(nameInBytes,valueInBytes);
    wrapper.addIndex(getHashKey(entityMetadata.getTableName(),discrColumn),getDouble(discrValue));
    wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(discrColumn,discrValue)),getDouble(discrValue));
  }
  String rowKey=null;
  if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
    rowKey=KunderaCoreUtils.prepareCompositeKey(entityMetadata,metaModel,id);
  }
 else {
    ObjectAccessor accessor=new ObjectAccessor();
    rowKey=accessor.toString(id);
  }
  String hashKey=getHashKey(entityMetadata.getTableName(),rowKey);
  if (resource != null && resource.isActive()) {
    ((Transaction)connection).hmset(getEncodedBytes(hashKey),wrapper.getColumns());
    ((Transaction)connection).zadd(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),getDouble(rowKey),rowKey);
    ((Transaction)connection).zadd(getHashKey(entityMetadata.getTableName(),getHashKey(((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName(),rowKey)),getDouble(rowKey),rowKey);
  }
 else {
    ((Pipeline)connection).hmset(getEncodedBytes(hashKey),wrapper.getColumns());
    ((Pipeline)connection).zadd(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),getDouble(rowKey),rowKey);
    ((Pipeline)connection).zadd(getHashKey(entityMetadata.getTableName(),getHashKey(((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName(),rowKey)),getDouble(rowKey),rowKey);
  }
  addIndex(connection,wrapper,rowKey,entityMetadata);
}

Fixed version (ground truth):
private void onPersist(EntityMetadata entityMetadata,Object entity,Object id,List<RelationHolder> rlHolders,Object connection){
  AttributeWrapper wrapper=wrap(entityMetadata,entity);
  if (rlHolders != null) {
    for (    RelationHolder relation : rlHolders) {
      String name=relation.getRelationName();
      Object value=relation.getRelationValue();
      byte[] valueInBytes=PropertyAccessorHelper.getBytes(value);
      byte[] nameInBytes=getEncodedBytes(name);
      String valueAsStr=PropertyAccessorHelper.getString(value);
      wrapper.addColumn(nameInBytes,valueInBytes);
      wrapper.addIndex(getHashKey(entityMetadata.getTableName(),name),getDouble(valueAsStr));
      wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(name,valueAsStr)),getDouble(valueAsStr));
    }
  }
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
  EntityType entityType=metaModel.entity(entityMetadata.getEntityClazz());
  String discrColumn=((AbstractManagedType)entityType).getDiscriminatorColumn();
  String discrValue=((AbstractManagedType)entityType).getDiscriminatorValue();
  if (discrColumn != null && discrValue != null) {
    byte[] valueInBytes=PropertyAccessorHelper.getBytes(discrValue);
    byte[] nameInBytes=getEncodedBytes(discrColumn);
    wrapper.addColumn(nameInBytes,valueInBytes);
    wrapper.addIndex(getHashKey(entityMetadata.getTableName(),discrColumn),getDouble(discrValue));
    wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(discrColumn,discrValue)),getDouble(discrValue));
  }
  String rowKey=null;
  if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
    rowKey=KunderaCoreUtils.prepareCompositeKey(entityMetadata,metaModel,id);
  }
 else {
    ObjectAccessor accessor=new ObjectAccessor();
    rowKey=accessor.toString(id);
  }
  String hashKey=getHashKey(entityMetadata.getTableName(),rowKey);
  if (resource != null && resource.isActive()) {
    ((Transaction)connection).hmset(getEncodedBytes(hashKey),wrapper.getColumns());
  }
 else {
    ((Pipeline)connection).hmset(getEncodedBytes(hashKey),wrapper.getColumns());
  }
  wrapper.addIndex(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),getDouble(rowKey));
  wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName(),rowKey)),getDouble(rowKey));
  addIndex(connection,wrapper,rowKey,entityMetadata);
}