nus-yam/ex-repair huggingface dataset:
Program: 176067
Project: 176067
Buggy source:
private void testCountResult(){
  Map<String,Client> clientMap=(Map<String,Client>)entityManager.getDelegate();
  ThriftClient tc=(ThriftClient)clientMap.get(SEC_IDX_CASSANDRA_TEST);
  tc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
  CQLTranslator translator=new CQLTranslator();
  String query="String_Node_Str" + translator.ensureCase(new StringBuilder(),"String_Node_Str",false).toString();
  Query q=entityManager.createNativeQuery(query,PersonCassandra.class);
  List noOfRows=q.getResultList();
  Assert.assertEquals(new Long(3),PropertyAccessorHelper.getObject(Long.class,((Column)noOfRows.get(0)).getValue()));
  Assert.assertEquals("String_Node_Str",PropertyAccessorHelper.getObject(String.class,((Column)noOfRows.get(0)).getName()));
  tc.setCqlVersion(CassandraConstants.CQL_VERSION_2_0);
}

Fixed version (ground truth):
private void testCountResult(){
  Map<String,Client> clientMap=(Map<String,Client>)entityManager.getDelegate();
  ThriftClient tc=(ThriftClient)clientMap.get(SEC_IDX_CASSANDRA_TEST);
  tc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
  CQLTranslator translator=new CQLTranslator();
  String query="String_Node_Str" + translator.ensureCase(new StringBuilder(),"String_Node_Str",false).toString();
  Query q=entityManager.createNativeQuery(query,PersonCassandra.class);
  List noOfRows=q.getResultList();
  Assert.assertEquals(new Long(3),PropertyAccessorHelper.getObject(Long.class,((Column)noOfRows.get(0)).getValue()));
  Assert.assertEquals("String_Node_Str",PropertyAccessorHelper.getObject(String.class,((Column)noOfRows.get(0)).getName()));
  entityManager.clear();
  q=entityManager.createNamedQuery("String_Node_Str");
  noOfRows=q.getResultList();
  Assert.assertEquals(3,noOfRows.size());
  tc.setCqlVersion(CassandraConstants.CQL_VERSION_2_0);
}
Program: 176068
Project: 176068
Buggy source:
@Test public void testCQLBatch(){
  String useNativeSql="String_Node_Str" + schema;
  EntityManagerFactory emf=getEntityManagerFactory();
  String createColumnFamily="String_Node_Str";
  String batchOps="String_Node_Str";
  EntityManager em=emf.createEntityManager();
  Map<String,Client> clientMap=(Map<String,Client>)em.getDelegate();
  PelopsClient pc=(PelopsClient)clientMap.get("String_Node_Str");
  pc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
  Query q=em.createNativeQuery(useNativeSql,CassandraBatchEntity.class);
  q.executeUpdate();
  pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
  q=em.createNativeQuery(createColumnFamily,CassandraBatchEntity.class);
  q.executeUpdate();
  pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
  q=em.createNativeQuery(batchOps,CassandraBatchEntity.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",CassandraBatchEntity.class);
  List<CassandraBatchEntity> results=q.getResultList();
  Assert.assertNotNull(results);
  Assert.assertEquals(3,results.size());
  createColumnFamily="String_Node_Str";
  em.createNativeQuery(createColumnFamily,CassandraBatchEntity.class).executeUpdate();
  createColumnFamily="String_Node_Str";
  em.createNativeQuery(createColumnFamily,CassandraBatchEntity.class).executeUpdate();
  batchOps="String_Node_Str";
  em.createNativeQuery(batchOps,CassandraBatchEntity.class).executeUpdate();
  emf.close();
}

Fixed version (ground truth):
@Test public void testCQLBatch(){
  String useNativeSql="String_Node_Str" + schema;
  EntityManagerFactory emf=getEntityManagerFactory();
  String createColumnFamily="String_Node_Str";
  String batchOps="String_Node_Str";
  EntityManager em=emf.createEntityManager();
  Map<String,Client> clientMap=(Map<String,Client>)em.getDelegate();
  PelopsClient pc=(PelopsClient)clientMap.get("String_Node_Str");
  pc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
  Query q=em.createNativeQuery(useNativeSql);
  q.executeUpdate();
  pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
  q=em.createNativeQuery(createColumnFamily,CassandraBatchEntity.class);
  q.executeUpdate();
  pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
  q=em.createNativeQuery(batchOps,CassandraBatchEntity.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",CassandraBatchEntity.class);
  List<CassandraBatchEntity> results=q.getResultList();
  Assert.assertNotNull(results);
  Assert.assertEquals(3,results.size());
  createColumnFamily="String_Node_Str";
  em.createNativeQuery(createColumnFamily,CassandraBatchEntity.class).executeUpdate();
  createColumnFamily="String_Node_Str";
  em.createNativeQuery(createColumnFamily,CassandraBatchEntity.class).executeUpdate();
  batchOps="String_Node_Str";
  em.createNativeQuery(batchOps,CassandraBatchEntity.class).executeUpdate();
  emf.close();
}
Program: 176069
Project: 176069
Buggy source:
/** 
 * Instantiates a new kundera persistence.
 */
public KunderaPersistence(){
  logger.info("String_Node_Str");
  new CoreLoader().load();
  this.providerUtil=new KunderaPersistenceProviderUtil(this);
  this.cache=new PersistenceUtilHelper.MetadataCache();
}

Fixed version (ground truth):
/** 
 * Instantiates a new kundera persistence.
 */
public KunderaPersistence(){
  this.providerUtil=new KunderaPersistenceProviderUtil(this);
  this.cache=new PersistenceUtilHelper.MetadataCache();
}
Program: 176070
Project: 176070
Buggy source:
@Override public synchronized final EntityManagerFactory createEntityManagerFactory(String persistenceUnit,Map map){
  if (persistenceUnit == null) {
    throw new KunderaException("String_Node_Str");
  }
synchronized (this) {
    try {
      initializeKundera(persistenceUnit,map);
      EntityManagerFactory emf=new EntityManagerFactoryImpl(persistenceUnit,map);
      return emf;
    }
 catch (    PersistenceUnitConfigurationException pcex) {
      logger.error("String_Node_Str");
      return null;
    }
  }
}

Fixed version (ground truth):
@Override public synchronized final EntityManagerFactory createEntityManagerFactory(String persistenceUnit,Map map){
synchronized (this) {
    try {
      EntityManagerFactory emf=new EntityManagerFactoryImpl(persistenceUnit,map);
      return emf;
    }
 catch (    PersistenceUnitConfigurationException pcex) {
      logger.error("String_Node_Str");
      return null;
    }
  }
}
Program: 176071
Project: 176071
Buggy source:
@Override public final EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info,Map map){
  return createEntityManagerFactory(info.getPersistenceUnitName(),map);
}

Fixed version (ground truth):
@Override public final EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info,Map map){
synchronized (this) {
    try {
      EntityManagerFactory emf=new EntityManagerFactoryImpl(info,map);
      return emf;
    }
 catch (    PersistenceUnitConfigurationException pcex) {
      logger.error("String_Node_Str");
      return null;
    }
  }
}
Program: 176072
Project: 176072
Buggy source:
@Override public Object getIdentifier(Object entity){
  Class<?> entityClass=entity.getClass();
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  if (entityMetadata == null) {
    throw new IllegalArgumentException(entityClass + "String_Node_Str");
  }
  return PropertyAccessorHelper.getId(entity,entityMetadata);
}

Fixed version (ground truth):
@Override public Object getIdentifier(Object entity){
  Class<?> entityClass=entity.getClass();
  return PropertyAccessorHelper.getId(entity,null);
}
Program: 176073
Project: 176073
Buggy source:
/** 
 * Method to handle
 * @param node
 */
public void persist(Node node){
  Object entity=node.getData();
  Object id=node.getEntityId();
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
  isUpdate=node.isUpdate();
  List<RelationHolder> relationHolders=getRelationHolders(node);
  onPersist(metadata,entity,id,relationHolders);
  id=PropertyAccessorHelper.getId(entity,metadata);
  node.setEntityId(id);
  indexNode(node,metadata);
}

Fixed version (ground truth):
/** 
 * Method to handle
 * @param node
 */
public void persist(Node node){
  Object entity=node.getData();
  Object id=node.getEntityId();
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(kunderaMetadata,node.getDataClass());
  isUpdate=node.isUpdate();
  List<RelationHolder> relationHolders=getRelationHolders(node);
  onPersist(metadata,entity,id,relationHolders);
  id=PropertyAccessorHelper.getId(entity,metadata);
  node.setEntityId(id);
  indexNode(node,metadata);
}
Program: 176075
Project: 176075
Buggy source:
/** 
 * Reads property file which is given in persistence unit
 * @param pu
 */
public void read(String pu){
  String propertyFileName=externalProperties != null ? (String)externalProperties.get(PersistenceProperties.KUNDERA_CLIENT_PROPERTY) : null;
  puMetadata=KunderaMetadataManager.getPersistenceUnitMetadata(pu);
  if (propertyFileName == null) {
    propertyFileName=puMetadata != null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_CLIENT_PROPERTY) : null;
  }
  if (propertyFileName != null && PropertyType.value(propertyFileName) != null && PropertyType.value(propertyFileName).equals(PropertyType.xml)) {
    onXml(onParseXML(propertyFileName,puMetadata));
  }
}

Fixed version (ground truth):
/** 
 * Reads property file which is given in persistence unit
 * @param pu
 */
public void read(String pu){
  String propertyFileName=externalProperties != null ? (String)externalProperties.get(PersistenceProperties.KUNDERA_CLIENT_PROPERTY) : null;
  if (propertyFileName == null) {
    propertyFileName=puMetadata != null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_CLIENT_PROPERTY) : null;
  }
  if (propertyFileName != null && PropertyType.value(propertyFileName) != null && PropertyType.value(propertyFileName).equals(PropertyType.xml)) {
    onXml(onParseXML(propertyFileName,puMetadata));
  }
}
Program: 176076
Project: 176076
Buggy source:
public AbstractPropertyReader(Map externalProperties){
  this.externalProperties=externalProperties;
}

Fixed version (ground truth):
public AbstractPropertyReader(Map externalProperties,final PersistenceUnitMetadata puMetadata){
  this.externalProperties=externalProperties;
  this.puMetadata=puMetadata;
}
Program: 176077
Project: 176077
Buggy source:
public AbstractSchemaConfiguration(final String[] persistenceUnits,final Map externalPropertyMap){
  this.persistenceUnits=persistenceUnits;
  this.externalPropertyMap=externalPropertyMap;
}

Fixed version (ground truth):
public AbstractSchemaConfiguration(final String[] persistenceUnits,final Map externalPropertyMap,final KunderaMetadata kunderaMetadata){
  this.persistenceUnits=persistenceUnits;
  this.externalPropertyMap=externalPropertyMap;
  this.kunderaMetadata=kunderaMetadata;
}
Program: 176078
Project: 176078
Buggy source:
/** 
 * Constructor parameterised with persistence units.
 * @param persistenceUnits persistence units.
 */
public ClientFactoryConfiguraton(Map externalProperties,String... persistenceUnits){
  super(persistenceUnits,externalProperties);
}

Fixed version (ground truth):
/** 
 * Constructor parameterised with persistence units.
 * @param persistenceUnits persistence units.
 */
public ClientFactoryConfiguraton(Map externalProperties,final KunderaMetadata kunderaMetadata,String... persistenceUnits){
  super(persistenceUnits,externalProperties,kunderaMetadata);
}
Program: 176079
Project: 176079
Buggy source:
@Override public void configure(){
  for (  String pu : persistenceUnits) {
    log.info("String_Node_Str" + pu);
    Map<String,Object> puProperty=KunderaCoreUtils.getExternalProperties(pu,externalPropertyMap,persistenceUnits);
    ClientResolver.getClientFactory(pu,puProperty).load(pu,puProperty);
  }
}

Fixed version (ground truth):
@Override public void configure(){
  for (  String pu : persistenceUnits) {
    log.info("String_Node_Str" + pu);
    Map<String,Object> puProperty=KunderaCoreUtils.getExternalProperties(pu,externalPropertyMap,persistenceUnits);
    ClientResolver.getClientFactory(pu,puProperty,kunderaMetadata).load(pu,puProperty);
  }
}
Program: 176080
Project: 176080
Buggy source:
public void buildClientFactoryMetadata(Map<String,ClientFactory> clientFactories){
  for (  String pu : persistenceUnits) {
    log.info("String_Node_Str" + pu);
    Map<String,Object> puProperty=KunderaCoreUtils.getExternalProperties(pu,mapExternalProperties,persistenceUnits);
    ClientFactory clientFactory=ClientResolver.getClientFactory(pu,puProperty);
    clientFactories.put(pu,clientFactory);
  }
  schemaConfiguration.configure();
  for (  String pu : persistenceUnits) {
    Map<String,Object> puProperty=KunderaCoreUtils.getExternalProperties(pu,mapExternalProperties,persistenceUnits);
    clientFactories.get(pu).load(pu,puProperty);
  }
}

Fixed version (ground truth):
public void buildClientFactoryMetadata(Map<String,ClientFactory> clientFactories,final KunderaMetadata kunderaMetadata){
  for (  String pu : persistenceUnits) {
    log.info("String_Node_Str" + pu);
    Map<String,Object> puProperty=KunderaCoreUtils.getExternalProperties(pu,mapExternalProperties,persistenceUnits);
    ClientFactory clientFactory=ClientResolver.getClientFactory(pu,puProperty,kunderaMetadata);
    clientFactories.put(pu,clientFactory);
  }
  schemaConfiguration.configure();
  for (  String pu : persistenceUnits) {
    Map<String,Object> puProperty=KunderaCoreUtils.getExternalProperties(pu,mapExternalProperties,persistenceUnits);
    clientFactories.get(pu).load(pu,puProperty);
  }
}
Program: 176081
Project: 176081
Buggy source:
public ClientMetadataBuilder(Map mapOfPuProperties,String... persistenceUnits){
  this.persistenceUnits=persistenceUnits;
  this.mapExternalProperties=mapOfPuProperties;
  this.schemaConfiguration=new SchemaConfiguration(mapOfPuProperties,persistenceUnits);
}

Fixed version (ground truth):
public ClientMetadataBuilder(Map mapOfPuProperties,final KunderaMetadata kunderaMetadata,String... persistenceUnits){
  this.persistenceUnits=persistenceUnits;
  this.mapExternalProperties=mapOfPuProperties;
  this.schemaConfiguration=new SchemaConfiguration(mapOfPuProperties,kunderaMetadata,persistenceUnits);
}
Program: 176082
Project: 176082
Buggy source:
/** 
 * Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.
 * @param table The name of the table
 * @param key The record key of the record to insert.
 * @param values A HashMap of field/value pairs to insert in the record
 * @return Zero on success, a non-zero error code on error
 */
public int insert(String table,String key,HashMap<String,ByteIterator> values){
  Mutator mutator=pool.createMutator();
  try {
    List<Column> columns=new ArrayList<Column>();
    for (    Map.Entry<String,ByteIterator> entry : values.entrySet()) {
      Column col=new Column();
      col.setName(ByteBuffer.wrap(entry.getKey().getBytes("String_Node_Str")));
      col.setValue(ByteBuffer.wrap(entry.getValue().toArray()));
      col.setTimestamp(System.currentTimeMillis());
      columns.add(col);
    }
    mutator.writeColumns(column_family,Bytes.fromUTF8(key),columns);
    mutator.execute(writeConsistencyLevel);
    return Ok;
  }
 catch (  Exception e) {
    logger.error(e);
    return Error;
  }
}

Fixed version (ground truth):
/** 
 * Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.
 * @param table The name of the table
 * @param key The record key of the record to insert.
 * @param values A HashMap of field/value pairs to insert in the record
 * @return Zero on success, a non-zero error code on error
 */
public int insert(String table,String key,HashMap<String,ByteIterator> values){
  Mutator mutator=Pelops.createMutator(_host + "String_Node_Str" + _port+ "String_Node_Str"+ _keyspace);
  try {
    List<Column> columns=new ArrayList<Column>();
    for (    Map.Entry<String,ByteIterator> entry : values.entrySet()) {
      Column col=new Column();
      col.setName(ByteBuffer.wrap(entry.getKey().getBytes("String_Node_Str")));
      col.setValue(ByteBuffer.wrap(entry.getValue().toArray()));
      col.setTimestamp(System.currentTimeMillis());
      columns.add(col);
    }
    mutator.writeColumns(column_family,Bytes.fromUTF8(key),columns);
    mutator.execute(writeConsistencyLevel);
    return Ok;
  }
 catch (  Exception e) {
    logger.error(e);
    return Error;
  }
}
Program: 176083
Project: 176083
Buggy source:
/** 
 * @param entityType
 * @param column
 * @param m
 * @param entity
 * @param embeddable
 * @param valueMap
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private static void onViaEmbeddable(Attribute column,Object entity,Metamodel metamodel,Map<String,Object> valueMap) throws InstantiationException, IllegalAccessException {
  EmbeddableType embeddable=metamodel.embeddable(((AbstractAttribute)column).getBindableJavaType());
  Field embeddedField=(Field)column.getJavaMember();
  Object embeddedDocumentObject=null;
  if (column.isCollection()) {
    Class embeddedObjectClass=PropertyAccessorHelper.getGenericClass(embeddedField);
    embeddedDocumentObject=valueMap.get(((AbstractAttribute)column).getJPAColumnName());
    if (embeddedDocumentObject != null) {
      Collection embeddedCollection=getCollectionFromDocumentList(metamodel,(List<Map<String,Object>>)embeddedDocumentObject,embeddedField.getType(),embeddedObjectClass,embeddable.getAttributes());
      PropertyAccessorHelper.set(entity,embeddedField,embeddedCollection);
    }
  }
 else {
    Object obj=PropertyAccessorHelper.getObject(entity,(Field)column.getJavaMember());
    if (obj == null) {
      obj=((AbstractAttribute)column).getBindableJavaType().newInstance();
    }
    embeddedDocumentObject=valueMap.get(((AbstractAttribute)column).getJPAColumnName());
    PropertyAccessorHelper.set(entity,embeddedField,getObjectFromDocument(metamodel,(Map<String,Object>)embeddedDocumentObject,embeddable.getAttributes(),obj));
  }
}

Fixed version (ground truth):
/** 
 * @param entityType
 * @param column
 * @param m
 * @param entity
 * @param embeddable
 * @param valueMap
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private static void onViaEmbeddable(Attribute column,Object entity,Metamodel metamodel,Map<String,Object> valueMap) throws InstantiationException, IllegalAccessException {
  EmbeddableType embeddable=metamodel.embeddable(((AbstractAttribute)column).getBindableJavaType());
  Field embeddedField=(Field)column.getJavaMember();
  Object embeddedDocumentObject=null;
  if (column.isCollection()) {
    Class embeddedObjectClass=PropertyAccessorHelper.getGenericClass(embeddedField);
    embeddedDocumentObject=valueMap.get(((AbstractAttribute)column).getJPAColumnName());
    if (embeddedDocumentObject != null) {
      Collection embeddedCollection=getCollectionFromDocumentList(metamodel,(List<Map<String,Object>>)embeddedDocumentObject,embeddedField.getType(),embeddedObjectClass,embeddable.getAttributes());
      PropertyAccessorHelper.set(entity,embeddedField,embeddedCollection);
    }
  }
 else {
    Object obj=PropertyAccessorHelper.getObject(entity,(Field)column.getJavaMember());
    if (obj == null) {
      obj=((AbstractAttribute)column).getBindableJavaType().newInstance();
    }
    embeddedDocumentObject=valueMap.get(((AbstractAttribute)column).getJPAColumnName());
    if (embeddedDocumentObject != null)     PropertyAccessorHelper.set(entity,embeddedField,getObjectFromDocument(metamodel,(Map<String,Object>)embeddedDocumentObject,embeddable.getAttributes(),obj));
  }
}
Program: 176085
Project: 176085
Buggy source:
/** 
 * Creates the query.
 * @param jpaQuery the jpa query
 * @return the query
 */
Query createQuery(String jpaQuery,final String persistenceUnit){
  Query query=new QueryResolver().getQueryImplementation(jpaQuery,getClient(persistenceUnit).getQueryImplementor(),this);
  return query;
}

Fixed version (ground truth):
/** 
 * Creates the query.
 * @param jpaQuery the jpa query
 * @return the query
 */
Query createQuery(String jpaQuery,final String persistenceUnit){
  Client client=getClient(persistenceUnit);
  EntityMetadata metadata=KunderaMetadataManager.getMetamodel(client.getPersistenceUnit()).getEntityMetadataMap().values().iterator().next();
  Query query=new QueryResolver().getQueryImplementation(jpaQuery,getClient(persistenceUnit).getQueryImplementor(),this,metadata);
  return query;
}
Program: 176086
Project: 176086
Buggy source:
public Query getQueryImplementation(String jpaQuery,Class queryClazz,final PersistenceDelegator persistenceDelegator){
  KunderaQuery kunderaQuery=new KunderaQuery(jpaQuery);
  kunderaQuery.isNativeQuery=true;
  Query query=null;
  try {
    Constructor constructor=queryClazz.getConstructor(KunderaQuery.class,PersistenceDelegator.class);
    query=(Query)constructor.newInstance(kunderaQuery,persistenceDelegator);
  }
 catch (  Exception e) {
    log.error(e.getMessage());
    throw new QueryHandlerException(e);
  }
  return query;
}

Fixed version (ground truth):
public Query getQueryImplementation(String jpaQuery,Class queryClazz,final PersistenceDelegator persistenceDelegator,EntityMetadata metadata){
  KunderaQuery kunderaQuery=new KunderaQuery(jpaQuery);
  kunderaQuery.isNativeQuery=true;
  try {
    Field entityClazzField=kunderaQuery.getClass().getDeclaredField("String_Node_Str");
    if (entityClazzField != null && !entityClazzField.isAccessible()) {
      entityClazzField.setAccessible(true);
    }
    entityClazzField.set(kunderaQuery,metadata.getEntityClazz());
  }
 catch (  Exception e) {
    log.error(e.getMessage());
    throw new QueryHandlerException(e);
  }
  Query query=null;
  try {
    Constructor constructor=queryClazz.getConstructor(KunderaQuery.class,PersistenceDelegator.class);
    query=(Query)constructor.newInstance(kunderaQuery,persistenceDelegator);
  }
 catch (  Exception e) {
    log.error(e.getMessage());
    throw new QueryHandlerException(e);
  }
  return query;
}
Program: 176087
Project: 176087
Buggy source:
Mutator getMutator(IThriftPool pool){
  IThriftPool iThriftPool=pool;
  boolean success=false;
  while (!success) {
    success=true;
    if (iThriftPool != null) {
      Node[] nodes=((CommonsBackedPool)iThriftPool).getCluster().getNodes();
      String host=nodes[0].getAddress();
      int thriftPort=((CommonsBackedPool)iThriftPool).getCluster().getConnectionConfig().getThriftPort();
      CassandraHost cassandraHost=((CassandraHostConfiguration)configuration).getCassandraHost(nodes[0].getAddress(),((CommonsBackedPool)pool).getCluster().getConnectionConfig().getThriftPort());
      if (cassandraHost.isTestOnBorrow()) {
        if (cassandraHost.isTestOnBorrow() && PelopsUtils.verifyConnection(host,thriftPort)) {
          return Pelops.createMutator(PelopsUtils.getPoolName(iThriftPool));
        }
        removePool(iThriftPool);
      }
 else {
        return Pelops.createMutator(PelopsUtils.getPoolName(iThriftPool));
      }
    }
    success=false;
    iThriftPool=getPoolUsingPolicy();
  }
  throw new KunderaException("String_Node_Str");
}

Fixed version (ground truth):
Mutator getMutator(IThriftPool pool){
  IThriftPool iThriftPool=pool;
  boolean success=false;
  while (!success) {
    success=true;
    if (iThriftPool != null) {
      Node[] nodes=((CommonsBackedPool)iThriftPool).getCluster().getNodes();
      String host=nodes[0].getAddress();
      int thriftPort=((CommonsBackedPool)iThriftPool).getCluster().getConnectionConfig().getThriftPort();
      CassandraHost cassandraHost=((CassandraHostConfiguration)configuration).getCassandraHost(nodes[0].getAddress(),((CommonsBackedPool)pool).getCluster().getConnectionConfig().getThriftPort());
      if (cassandraHost.isTestOnBorrow()) {
        if (cassandraHost.isTestOnBorrow() && PelopsUtils.verifyConnection(host,thriftPort)) {
          return Pelops.createMutator(PelopsUtils.getPoolName(iThriftPool));
        }
        removePool(iThriftPool);
      }
 else {
        return iThriftPool.createMutator();
      }
    }
    success=false;
    iThriftPool=getPoolUsingPolicy();
  }
  throw new KunderaException("String_Node_Str");
}
Program: 176088
Project: 176088
Buggy source:
@Override public void handleMerge(NodeStateContext nodeStateContext){
  Object copiedNodeData=ObjectUtils.deepCopy(nodeStateContext.getData());
  nodeStateContext.setData(copiedNodeData);
}

Fixed version (ground truth):
@Override public void handleMerge(NodeStateContext nodeStateContext){
  Object copiedNodeData=ObjectUtils.deepCopy(nodeStateContext.getData());
  nodeStateContext.setData(copiedNodeData);
  moveNodeToNextState(nodeStateContext,new ManagedState());
  nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
}
Program: 176089
Project: 176089
Buggy source:
/** 
 * Recursively fetches associated entities for a given <code>entity</code>
 * @param entity
 * @param relationsMap
 * @param client
 * @param m
 * @param pd
 * @return
 */
private Object handleAssociation(final Object entity,final Map<String,Object> relationsMap,final EntityMetadata m,final PersistenceDelegator pd,boolean lazilyloaded){
  for (  Relation relation : m.getRelations()) {
    ForeignKey relationType=relation.getType();
    Object relationalObject=PropertyAccessorHelper.getObject(entity,relation.getProperty());
    if (KunderaCoreUtils.isEmptyOrNull(relationalObject) || ProxyHelper.isProxyOrCollection(relationalObject)) {
      onRelation(entity,relationsMap,m,pd,relation,relationType,lazilyloaded);
    }
  }
  return entity;
}

Fixed version (ground truth):
/** 
 * Recursively fetches associated entities for a given <code>entity</code>
 * @param entity
 * @param relationsMap
 * @param client
 * @param m
 * @param pd
 * @return
 */
private Object handleAssociation(final Object entity,final Map<String,Object> relationsMap,final EntityMetadata m,final PersistenceDelegator pd,boolean lazilyloaded){
  for (  Relation relation : m.getRelations()) {
    ForeignKey relationType=relation.getType();
    Object relationalObject=PropertyAccessorHelper.getObject(entity,relation.getProperty());
    if (KunderaCoreUtils.isEmptyOrNull(relationalObject) || ProxyHelper.isProxyOrCollection(relationalObject)) {
      onRelation(entity,relationsMap,m,pd,relation,relationType,lazilyloaded);
    }
 else     if (!ProxyHelper.isProxyOrCollection(relationalObject) && Map.class.isAssignableFrom(relationalObject.getClass())) {
      Map relationalMap=(Map)relationalObject;
      for (      Map.Entry entry : (Set<Map.Entry>)relationalMap.entrySet()) {
        Object entityObject=entry.getValue();
        if (entityObject != null) {
          EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(entityObject.getClass());
          PersistenceCacheManager.addEntityToPersistenceCache(entityObject,pd,PropertyAccessorHelper.getId(entityObject,metadata));
        }
      }
    }
  }
  return entity;
}
Program: 176091
Project: 176091
Buggy source:
/** 
 * parse and process non unary relations {e.g. 1-M and M-M}
 * @return true, if is a non unary relation and processed.
 */
private boolean onNonUnaryRelation(){
  if (!relation.isUnary()) {
    if (Collection.class.isAssignableFrom(target.getClass())) {
      Collection childrenObjects=(Collection)target;
      for (      Object childObj : childrenObjects) {
        if (childObj != null) {
          this.generator.onBuildChildNode(childObj,metadata,this.pd,pc,source,relation);
        }
      }
    }
 else     if (Map.class.isAssignableFrom(target.getClass())) {
      Map childrenObjects=(Map)target;
      if (childrenObjects != null && !ProxyHelper.isProxyCollection(childrenObjects)) {
        for (        Map.Entry entry : (Set<Map.Entry>)childrenObjects.entrySet()) {
          Object relObject=entry.getKey();
          Object entityObject=entry.getValue();
          Node childNode=this.generator.generate(entityObject,pd,pc,null);
          if (childNode != null) {
            if (StringUtils.isEmpty(relation.getMappedBy()) && relation.getProperty().getAnnotation(MapKeyJoinColumn.class) != null) {
              NodeLink nodeLink=new NodeLink(source.getNodeId(),childNode.getNodeId());
              this.generator.setLink(source,relation,childNode,nodeLink);
              nodeLink.addLinkProperty(LinkProperty.LINK_VALUE,relObject);
            }
          }
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * parse and process non unary relations {e.g. 1-M and M-M}
 * @return true, if is a non unary relation and processed.
 */
private boolean onNonUnaryRelation(){
  if (!relation.isUnary()) {
    if (Collection.class.isAssignableFrom(target.getClass())) {
      Collection childrenObjects=(Collection)target;
      for (      Object childObj : childrenObjects) {
        if (childObj != null) {
          this.generator.onBuildChildNode(childObj,metadata,this.pd,pc,source,relation);
        }
      }
    }
 else     if (Map.class.isAssignableFrom(target.getClass())) {
      Map childrenObjects=(Map)target;
      if (childrenObjects != null && !ProxyHelper.isProxyCollection(childrenObjects)) {
        for (        Map.Entry entry : (Set<Map.Entry>)childrenObjects.entrySet()) {
          Object relObject=entry.getKey();
          Object entityObject=entry.getValue();
          if (entityObject != null) {
            Node childNode=this.generator.generate(entityObject,pd,pc,null);
            if (childNode != null) {
              if (StringUtils.isEmpty(relation.getMappedBy()) && relation.getProperty().getAnnotation(MapKeyJoinColumn.class) != null) {
                NodeLink nodeLink=new NodeLink(source.getNodeId(),childNode.getNodeId());
                this.generator.setLink(source,relation,childNode,nodeLink);
                nodeLink.addLinkProperty(LinkProperty.LINK_VALUE,relObject);
              }
            }
          }
        }
      }
    }
    return true;
  }
  return false;
}
Program: 176092
Project: 176092
Buggy source:
private void createKeyspace(){
  try {
    CassandraCli.executeCqlQuery("String_Node_Str","String_Node_Str");
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
private void createKeyspace(){
  try {
    CassandraCli.getClient().execute_cql3_query(ByteBuffer.wrap("String_Node_Str".getBytes("String_Node_Str")),Compression.NONE,ConsistencyLevel.ONE);
  }
 catch (  Exception e) {
  }
}
Program: 176093
Project: 176093
Buggy source:
/** 
 * Sets the up.
 * @throws Exception the exception
 */
@Before public void setUp() throws Exception {
  CassandraCli.cassandraSetUp();
  String nativeSql="String_Node_Str" + schema + "String_Node_Str";
  CassandraCli.executeCqlQuery(nativeSql,schema);
  emf=getEntityManagerFactory();
}

Fixed version (ground truth):
/** 
 * Sets the up.
 * @throws Exception the exception
 */
@Before public void setUp() throws Exception {
  CassandraCli.cassandraSetUp();
  String nativeSql="String_Node_Str" + schema + "String_Node_Str";
  CassandraCli.getClient().execute_cql3_query(ByteBuffer.wrap(nativeSql.getBytes("String_Node_Str")),Compression.NONE,ConsistencyLevel.ONE);
  emf=getEntityManagerFactory();
}
Program: 176094
Project: 176094
Buggy source:
/** 
 * Sets the up internal.
 * @param colFamilies the new up internal
 */
protected void setUpInternal(String... colFamilies){
  dao=new IMDBDaoImpl(persistenceUnits);
  em=null;
  dao.closeEntityManager();
  dao.closeEntityManagerFactory();
  em=dao.getEntityManager(persistenceUnits);
  kunderaMetadata=((EntityManagerFactoryImpl)em.getEntityManagerFactory()).getKunderaMetadataInstance();
  this.colFamilies=colFamilies;
}

Fixed version (ground truth):
/** 
 * Sets the up internal.
 * @param colFamilies the new up internal
 */
protected void setUpInternal(String... colFamilies){
  dao=new IMDBDaoImpl(persistenceUnits);
  dao.closeEntityManager();
  dao.closeEntityManagerFactory();
  em=dao.getEntityManager(persistenceUnits);
  kunderaMetadata=((EntityManagerFactoryImpl)em.getEntityManagerFactory()).getKunderaMetadataInstance();
  this.colFamilies=colFamilies;
}
Program: 176095
Project: 176095
Buggy source:
@Override public synchronized void init(Map<?,?> properties){
  if (manager != null) {
    log.warn("String_Node_Str");
    return;
  }
  initializing=true;
  try {
    String configurationResourceName=null;
    if (properties != null) {
      configurationResourceName=(String)properties.get(NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME);
    }
    if (configurationResourceName == null || configurationResourceName.length() == 0) {
      manager=new CacheManager();
    }
 else {
      if (!configurationResourceName.startsWith("String_Node_Str")) {
        configurationResourceName="String_Node_Str" + configurationResourceName;
        log.info("String_Node_Str" + configurationResourceName + "String_Node_Str"+ "String_Node_Str");
      }
      URL url=loadResource(configurationResourceName);
      manager=new CacheManager(url);
    }
  }
 catch (  net.sf.ehcache.CacheException e) {
    if (e.getMessage().startsWith("String_Node_Str" + "String_Node_Str")) {
      throw new CacheException("String_Node_Str",e);
    }
 else {
      throw new CacheException(e);
    }
  }
 finally {
    initializing=false;
  }
}

Fixed version (ground truth):
@Override public synchronized void init(Map<?,?> properties){
  if (manager != null) {
    log.warn("String_Node_Str");
    return;
  }
  initializing=true;
  try {
    String configurationResourceName=null;
    if (properties != null) {
      configurationResourceName=(String)properties.get(NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME);
    }
    if (configurationResourceName == null || configurationResourceName.length() == 0) {
      manager=CacheManager.create();
    }
 else {
      if (!configurationResourceName.startsWith("String_Node_Str")) {
        configurationResourceName="String_Node_Str" + configurationResourceName;
        log.info("String_Node_Str" + configurationResourceName + "String_Node_Str"+ "String_Node_Str");
      }
      URL url=loadResource(configurationResourceName);
      manager=CacheManager.create(url);
    }
  }
 catch (  net.sf.ehcache.CacheException e) {
    if (e.getMessage().startsWith("String_Node_Str" + "String_Node_Str")) {
      throw new CacheException("String_Node_Str",e);
    }
 else {
      throw new CacheException(e);
    }
  }
 finally {
    initializing=false;
  }
}
Program: 176096
Project: 176096
Buggy source:
@Override public void shutdown(){
  if (manager != null) {
    manager.shutdown();
    manager=null;
  }
  cache=null;
}

Fixed version (ground truth):
@Override public void shutdown(){
  if (manager != null) {
    manager.removalAll();
    manager=null;
  }
  cache=null;
}
Program: 176097
Project: 176097
Buggy source:
@Override public void evictAll(){
  ehcache.removeAll();
}

Fixed version (ground truth):
@Override public void evictAll(){
  if (ehcache.getStatus().equals(Status.STATUS_ALIVE)) {
    ehcache.removeAll();
  }
}
Program: 176098
Project: 176098
Buggy source:
/** 
 * Populate using lucene.
 * @param m the m
 * @param client the client
 * @param result the result
 * @param columnsToSelect List of column names to be selected (rest should be ignored)
 * @return the list
 */
protected List<Object> populateUsingLucene(EntityMetadata m,Client client,List<Object> result,String[] columnsToSelect){
  String luceneQ=getLuceneQueryFromJPAQuery();
  Map<String,Object> searchFilter=client.getIndexManager().search(m.getEntityClazz(),luceneQ,Constants.INVALID,Constants.INVALID);
  String[] primaryKeys=searchFilter.values().toArray(new String[]{});
  Set<String> uniquePKs=new HashSet<String>(Arrays.asList(primaryKeys));
  if (kunderaQuery.isAliasOnly() || !m.getType().isSuperColumnFamilyMetadata()) {
    result=(List<Object>)client.findAll(m.getEntityClazz(),columnsToSelect,uniquePKs.toArray());
  }
 else {
    return (List<Object>)persistenceDelegeator.find(m.getEntityClazz(),uniquePKs.toArray());
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Populate using lucene.
 * @param m the m
 * @param client the client
 * @param result the result
 * @param columnsToSelect List of column names to be selected (rest should be ignored)
 * @return the list
 */
protected List<Object> populateUsingLucene(EntityMetadata m,Client client,List<Object> result,String[] columnsToSelect){
  String luceneQ=getLuceneQueryFromJPAQuery();
  Map<String,Object> searchFilter=client.getIndexManager().search(m.getEntityClazz(),luceneQ,Constants.INVALID,getMaxResults());
  String[] primaryKeys=searchFilter.values().toArray(new String[]{});
  Set<String> uniquePKs=new HashSet<String>(Arrays.asList(primaryKeys));
  if (kunderaQuery.isAliasOnly() || !m.getType().isSuperColumnFamilyMetadata()) {
    result=(List<Object>)client.findAll(m.getEntityClazz(),columnsToSelect,uniquePKs.toArray());
  }
 else {
    return (List<Object>)persistenceDelegeator.find(m.getEntityClazz(),uniquePKs.toArray());
  }
  return result;
}
Program: 176101
Project: 176101
Buggy source:
@Override public boolean contains(Class arg0,Object arg1){
  return (ehcache.get(arg1) != null);
}

Fixed version (ground truth):
@Override public boolean contains(Class arg0,Object arg1){
  if (isAlive()) {
    return (ehcache.get(arg1) != null);
  }
  return false;
}
Program: 176102
Project: 176102
Buggy source:
@Override public void evictAll(){
  if (ehcache.getStatus().equals(Status.STATUS_ALIVE)) {
    ehcache.removeAll();
  }
}

Fixed version (ground truth):
@Override public void evictAll(){
  if (isAlive()) {
    ehcache.removeAll();
  }
}
Program: 176103
Project: 176103
Buggy source:
@Override public int size(){
  return ehcache.getSize();
}

Fixed version (ground truth):
@Override public int size(){
  if (isAlive()) {
    return ehcache.getSize();
  }
  return 0;
}
Program: 176104
Project: 176104
Buggy source:
@Override public Object get(Object key){
  Element element=ehcache.get(key);
  return element == null ? null : element.getObjectValue();
}

Fixed version (ground truth):
@Override public Object get(Object key){
  Element element=null;
  if (isAlive()) {
    element=ehcache.get(key);
  }
  return element == null ? null : element.getObjectValue();
}
Program: 176105
Project: 176105
Buggy source:
@Override public void put(Object key,Object value){
  ehcache.put(new Element(key,value));
}

Fixed version (ground truth):
@Override public void put(Object key,Object value){
  if (isAlive())   ehcache.put(new Element(key,value));
}
Program: 176106
Project: 176106
Buggy source:
@Override public void evict(Class arg0,Object arg1){
  ehcache.remove(arg1);
}

Fixed version (ground truth):
@Override public void evict(Class arg0,Object arg1){
  if (isAlive())   ehcache.remove(arg1);
}
Program: 176107
Project: 176107
Buggy source:
/** 
 * Translates kundera query into collection of to be applied HBase filter/s.
 * @param query kundera query.
 * @param m entity's metadata.
 */
void translate(KunderaQuery query,EntityMetadata m,ClientMetadata clientMetadata){
  String idColumn=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
  for (  Object obj : query.getFilterClauseQueue()) {
    boolean isIdColumn=false;
    if (obj instanceof FilterClause) {
      String condition=((FilterClause)obj).getCondition();
      String name=((FilterClause)obj).getProperty();
      Object value=((FilterClause)obj).getValue();
      if (idColumn.equalsIgnoreCase(name)) {
        isIdColumn=true;
      }
      onParseFilter(condition,name,value,isIdColumn,m);
    }
 else {
      String opr=obj.toString();
      if (MetadataUtils.useSecondryIndex(clientMetadata)) {
        if (opr.trim().equalsIgnoreCase("String_Node_Str")) {
          log.error("String_Node_Str");
          throw new QueryHandlerException("String_Node_Str" + opr + "String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Translates kundera query into collection of to be applied HBase filter/s.
 * @param query kundera query.
 * @param m entity's metadata.
 */
void translate(KunderaQuery query,EntityMetadata m,ClientMetadata clientMetadata){
  String idColumn=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
  boolean useFilter=MetadataUtils.useSecondryIndex(clientMetadata);
  for (  Object obj : query.getFilterClauseQueue()) {
    boolean isIdColumn=false;
    if (obj instanceof FilterClause) {
      String condition=((FilterClause)obj).getCondition();
      String name=((FilterClause)obj).getProperty();
      Object value=((FilterClause)obj).getValue();
      if (idColumn.equalsIgnoreCase(name)) {
        isIdColumn=true;
      }
      onParseFilter(condition,name,value,isIdColumn,m,useFilter);
    }
 else {
      String opr=obj.toString();
      if (MetadataUtils.useSecondryIndex(clientMetadata)) {
        if (opr.trim().equalsIgnoreCase("String_Node_Str")) {
          log.error("String_Node_Str");
          throw new QueryHandlerException("String_Node_Str" + opr + "String_Node_Str");
        }
      }
    }
  }
}
Program: 176108
Project: 176108
Buggy source:
/** 
 * On parsing filter clause(e.g. WHERE clause).
 * @param condition condition
 * @param name column name.
 * @param value column value.
 * @param isIdColumn if it is an id column.
 * @param m entity metadata.
 */
private void onParseFilter(String condition,String name,Object value,boolean isIdColumn,EntityMetadata m){
  CompareOp operator=HBaseUtils.getOperator(condition,isIdColumn);
  byte[] valueInBytes=getBytes(name,m,value);
  if (!isIdColumn) {
    List<String> columns=null;
    if (new StringTokenizer(name,"String_Node_Str").countTokens() > 1) {
      columns=getTranslatedColumns(m,new String[]{name},0);
    }
    if (columns != null && !columns.isEmpty()) {
      name=columns.get(0);
    }
    Filter f=new SingleColumnValueFilter(Bytes.toBytes(m.getTableName()),Bytes.toBytes(name),operator,valueInBytes);
    addToFilter(f);
  }
 else {
    if (operator.equals(CompareOp.GREATER_OR_EQUAL) || operator.equals(CompareOp.GREATER)) {
      startRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.LESS_OR_EQUAL) || operator.equals(CompareOp.LESS)) {
      endRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.EQUAL)) {
      rowKey=getBytes(m.getIdAttribute().getName(),m,value);
      endRow=null;
      isFindById=true;
    }
  }
  this.isIdColumn=isIdColumn;
}

Fixed version (ground truth):
/** 
 * On parsing filter clause(e.g. WHERE clause).
 * @param condition condition
 * @param name column name.
 * @param value column value.
 * @param isIdColumn if it is an id column.
 * @param m entity metadata.
 */
private void onParseFilter(String condition,String name,Object value,boolean isIdColumn,EntityMetadata m,boolean useFilter){
  CompareOp operator=HBaseUtils.getOperator(condition,isIdColumn,useFilter);
  byte[] valueInBytes=getBytes(name,m,value);
  if (!isIdColumn) {
    List<String> columns=null;
    if (new StringTokenizer(name,"String_Node_Str").countTokens() > 1) {
      columns=getTranslatedColumns(m,new String[]{name},0);
    }
    if (columns != null && !columns.isEmpty()) {
      name=columns.get(0);
    }
    Filter f=new SingleColumnValueFilter(Bytes.toBytes(m.getTableName()),Bytes.toBytes(name),operator,valueInBytes);
    addToFilter(f);
  }
 else {
    if (operator.equals(CompareOp.GREATER_OR_EQUAL) || operator.equals(CompareOp.GREATER)) {
      startRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.LESS_OR_EQUAL) || operator.equals(CompareOp.LESS)) {
      endRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.EQUAL)) {
      rowKey=getBytes(m.getIdAttribute().getName(),m,value);
      endRow=null;
      isFindById=true;
    }
  }
  this.isIdColumn=isIdColumn;
}
Program: 176109
Project: 176109
Buggy source:
/** 
 * Gets the operator.
 * @param condition the condition
 * @param idPresent the id present
 * @return the operator
 */
public static CompareOp getOperator(String condition,boolean idPresent){
  if (condition.equals("String_Node_Str")) {
    return CompareOp.EQUAL;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.GREATER;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.LESS;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.GREATER_OR_EQUAL;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.LESS_OR_EQUAL;
  }
 else {
    if (!idPresent) {
      throw new UnsupportedOperationException("String_Node_Str" + condition + "String_Node_Str");
    }
 else {
      throw new UnsupportedOperationException("String_Node_Str" + condition + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets the operator.
 * @param condition the condition
 * @param idPresent the id present
 * @return the operator
 */
public static CompareOp getOperator(String condition,boolean idPresent,boolean useFilter){
  if (condition.equals("String_Node_Str")) {
    return CompareOp.EQUAL;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.GREATER;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.LESS;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.GREATER_OR_EQUAL;
  }
 else   if (condition.equals("String_Node_Str")) {
    return CompareOp.LESS_OR_EQUAL;
  }
 else   if (useFilter) {
    if (!idPresent) {
      throw new UnsupportedOperationException("String_Node_Str" + condition + "String_Node_Str");
    }
 else {
      throw new UnsupportedOperationException("String_Node_Str" + condition + "String_Node_Str");
    }
  }
  return null;
}
Program: 176110
Project: 176110
Buggy source:
@Test public void testOneToMany() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
  AddressU1M address1=new AddressU1M();
  address1.setAddressId("String_Node_Str");
  address1.setStreet("String_Node_Str");
  AddressU1M address2=new AddressU1M();
  address2.setAddressId("String_Node_Str");
  address2.setStreet("String_Node_Str");
  Set<AddressU1M> addressess=new HashSet<AddressU1M>();
  addressess.add(address1);
  addressess.add(address2);
  PersonU1M p1=new PersonU1M();
  p1.setPersonName("String_Node_Str");
  p1.setPersonId("String_Node_Str");
  p1.setAddresses(addressess);
  em.persist(p1);
  PersistenceDelegator delegator=CoreTestUtilities.getDelegator(em);
  Map<String,Object> relationMap=null;
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(PersonU1M.class);
  CoreTestEntityReader reader=new CoreTestEntityReader();
  p1.setAddresses(null);
  reader.recursivelyFindEntities(p1,relationMap,metadata,delegator,false);
  Assert.assertNotNull(p1.getAddresses());
  Assert.assertTrue(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
  p1.setAddresses(null);
  reader.recursivelyFindEntities(p1,relationMap,metadata,delegator,true);
  Assert.assertNotNull(p1.getAddresses());
  Assert.assertFalse(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
}

Fixed version (ground truth):
@Test public void testOneToMany() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
  AddressU1M address1=new AddressU1M();
  address1.setAddressId("String_Node_Str");
  address1.setStreet("String_Node_Str");
  AddressU1M address2=new AddressU1M();
  address2.setAddressId("String_Node_Str");
  address2.setStreet("String_Node_Str");
  Set<AddressU1M> addressess=new HashSet<AddressU1M>();
  addressess.add(address1);
  addressess.add(address2);
  PersonU1M p1=new PersonU1M();
  p1.setPersonName("String_Node_Str");
  p1.setPersonId("String_Node_Str");
  p1.setAddresses(addressess);
  em.persist(p1);
  PersistenceDelegator delegator=CoreTestUtilities.getDelegator(em);
  Map<String,Object> relationMap=null;
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(PersonU1M.class);
  CoreTestEntityReader reader=new CoreTestEntityReader();
  p1.setAddresses(null);
  reader.recursivelyFindEntities(p1,relationMap,metadata,delegator,false);
  Assert.assertNotNull(p1.getAddresses());
  Assert.assertTrue(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
  reader.recursivelyFindEntities(p1,relationMap,metadata,delegator,true);
  Assert.assertNotNull(p1.getAddresses());
  Assert.assertFalse(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
}