Program: 63360
Project: 63360
Buggy source:
/** 
 * Finds all bidirectional relationships of the given entity with Cascade=PERSIST and sets reference to the parent object. This method is called on creating new entities in JPARS v2.0 only.
 * @param context       the persistence context.
 * @param descriptor    descriptor of the entity passed in 'entity' parameter.
 * @param entity        entity to process.
 */
private void processBidirectionalRelationships(PersistenceContext context,ClassDescriptor descriptor,Object entity){
  final List<DatabaseMapping> mappings=descriptor.getMappings();
  for (  DatabaseMapping mapping : mappings) {
    if ((mapping != null) && (mapping instanceof ForeignReferenceMapping)) {
      final ForeignReferenceMapping jpaMapping=(ForeignReferenceMapping)mapping;
      final Object attributeValue=mapping.getAttributeAccessor().getAttributeValueFromObject(entity);
      if (jpaMapping != null && jpaMapping.isCascadePersist()) {
        if (jpaMapping.getMappedBy() != null) {
          final ClassDescriptor inverseDescriptor=context.getDescriptor(jpaMapping.getReferenceDescriptor().getAlias());
          if (inverseDescriptor != null) {
            final DatabaseMapping inverseMapping=inverseDescriptor.getMappingForAttributeName(jpaMapping.getMappedBy());
            if (inverseMapping != null) {
              if (attributeValue != null) {
                if (attributeValue instanceof ValueHolder) {
                  final ValueHolder holder=(ValueHolder)attributeValue;
                  final Object obj=holder.getValue();
                  if (obj != null) {
                    inverseMapping.setAttributeValueInObject(obj,entity);
                  }
                }
 else                 if (attributeValue instanceof Collection) {
                  final Collection collection=(Collection)attributeValue;
                  if (!collection.isEmpty()) {
                    for (                    Object obj : collection) {
                      inverseMapping.setAttributeValueInObject(obj,entity);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Finds all bidirectional relationships of the given entity with Cascade=PERSIST and sets reference to the parent object. This method is called on creating new entities in JPARS v2.0 only.
 * @param context       the persistence context.
 * @param descriptor    descriptor of the entity passed in 'entity' parameter.
 * @param entity        entity to process.
 */
private void processBidirectionalRelationships(PersistenceContext context,ClassDescriptor descriptor,Object entity){
  final List<DatabaseMapping> mappings=descriptor.getMappings();
  for (  DatabaseMapping mapping : mappings) {
    if ((mapping != null) && (mapping instanceof ForeignReferenceMapping)) {
      final ForeignReferenceMapping jpaMapping=(ForeignReferenceMapping)mapping;
      final Object attributeValue=mapping.getAttributeAccessor().getAttributeValueFromObject(entity);
      if (jpaMapping.isCascadePersist()) {
        if (jpaMapping.getMappedBy() != null) {
          final ClassDescriptor inverseDescriptor=context.getDescriptor(jpaMapping.getReferenceDescriptor().getAlias());
          if (inverseDescriptor != null) {
            final DatabaseMapping inverseMapping=inverseDescriptor.getMappingForAttributeName(jpaMapping.getMappedBy());
            if (inverseMapping != null) {
              if (attributeValue != null) {
                if (attributeValue instanceof ValueHolder) {
                  final ValueHolder holder=(ValueHolder)attributeValue;
                  final Object obj=holder.getValue();
                  if (obj != null) {
                    inverseMapping.setAttributeValueInObject(obj,entity);
                  }
                }
 else                 if (attributeValue instanceof Collection) {
                  final Collection collection=(Collection)attributeValue;
                  if (!collection.isEmpty()) {
                    for (                    Object obj : collection) {
                      inverseMapping.setAttributeValueInObject(obj,entity);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}