nus-yam/ex-repair huggingface dataset:
Program: 176646
Project: 176646
Buggy source:
/** 
 * Writes an entity into Persistence cache. (Actual database write is done while flushing)
 */
public void persist(Object e){
  if (e == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityMetadata metadata=getMetadata(e.getClass());
  idGenerator.setGeneratedIdIfApplicable(e,metadata,getClient(metadata));
  if (!validator.isValidEntityObject(e)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState());
  Node node=graph.getHeadNode();
  lock.writeLock().lock();
  node.persist();
  flushManager.buildFlushStack(node,com.impetus.kundera.persistence.context.EventLog.EventType.INSERT);
  flush();
  getPersistenceCache().getMainCache().addHeadNode(node);
  lock.writeLock().unlock();
  graph.clear();
  graph=null;
  getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + e.getClass());
  }
}

Fixed version (ground truth):
/** 
 * Writes an entity into Persistence cache. (Actual database write is done while flushing)
 */
public void persist(Object e){
  if (e == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityMetadata metadata=getMetadata(e.getClass());
  idGenerator.setGeneratedIdIfApplicable(e,metadata,getClient(metadata));
  if (!validator.isValidEntityObject(e)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
  }
 catch (  Exception es) {
    es.printStackTrace();
  }
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState());
  Node node=graph.getHeadNode();
  lock.writeLock().lock();
  node.persist();
  flushManager.buildFlushStack(node,com.impetus.kundera.persistence.context.EventLog.EventType.INSERT);
  flush();
  getPersistenceCache().getMainCache().addHeadNode(node);
  lock.writeLock().unlock();
  graph.clear();
  graph=null;
  getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + e.getClass());
  }
}
Program: 176647
Project: 176647
Buggy source:
/** 
 * Gets the entity manager factory.
 * @param useLucene
 * @param property
 * @return the entity manager factory
 */
private EntityManagerFactoryImpl getEntityManagerFactory(){
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  Map<String,List<String>> clazzToPu=new HashMap<String,List<String>>();
  List<String> pus=new ArrayList<String>();
  pus.add(_persistenceUnit);
  clazzToPu.put(PersonnelDTO.class.getName(),pus);
  appMetadata.setClazzToPuMap(clazzToPu);
  EntityMetadata m=new EntityMetadata(PersonnelDTO.class);
  TableProcessor processor=new TableProcessor(null);
  processor.process(PersonnelDTO.class,m);
  m.setPersistenceUnit(_persistenceUnit);
  MetamodelImpl metaModel=new MetamodelImpl();
  metaModel.addEntityMetadata(PersonnelDTO.class,m);
  metaModel.assignManagedTypes(appMetadata.getMetaModelBuilder(_persistenceUnit).getManagedTypes());
  metaModel.assignEmbeddables(appMetadata.getMetaModelBuilder(_persistenceUnit).getEmbeddables());
  metaModel.assignMappedSuperClass(appMetadata.getMetaModelBuilder(_persistenceUnit).getMappedSuperClassTypes());
  appMetadata.getMetamodelMap().put(_persistenceUnit,metaModel);
  return null;
}

Fixed version (ground truth):
/** 
 * Gets the entity manager factory.
 * @param useLucene
 * @param property
 * @return the entity manager factory
 */
private EntityManagerFactory getEntityManagerFactory(){
  return Persistence.createEntityManagerFactory(_persistenceUnit);
}
Program: 176648
Project: 176648
Buggy source:
@PrePersist public void handledPrePersist(PersonnelDTO user){
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@PrePersist public void handledPrePersist(PersonnelDTO user){
  user.setLastName("String_Node_Str");
}
Program: 176649
Project: 176649
Buggy source:
@Test public void testCRUDWithBatch(){
  Map<String,String> batchProperty=new HashMap<String,String>(1);
  batchProperty.put(PersistenceProperties.KUNDERA_BATCH_SIZE,"String_Node_Str");
  emf=Persistence.createEntityManagerFactory(REDIS_PU,batchProperty);
  EntityManager em=emf.createEntityManager();
  Map<String,Client> clients=(Map<String,Client>)em.getDelegate();
  RedisClient client=(RedisClient)clients.get(REDIS_PU);
  Assert.assertEquals(5,((Batcher)client).getBatchSize());
  final String originalName="String_Node_Str";
  for (int i=0; i < 9; i++) {
    PersonRedis object=new PersonRedis();
    object.setAge(32);
    object.setPersonId(ROW_KEY + i);
    object.setPersonName(originalName);
    em.persist(object);
    if (i >= 5) {
      PersonRedis result=(PersonRedis)client.find(PersonRedis.class,ROW_KEY + i);
      Assert.assertNull(result);
    }
 else     if (i > 0 && i % 4 == 0) {
      PersonRedis result=(PersonRedis)client.find(PersonRedis.class,ROW_KEY + i);
      Assert.assertNotNull(result);
      Assert.assertEquals(result.getPersonId(),object.getPersonId());
      Assert.assertEquals(result.getAge(),object.getAge());
      Assert.assertEquals(result.getPersonName(),object.getPersonName());
    }
  }
  em.close();
}

Fixed version (ground truth):
@Test public void testCRUDWithBatch(){
  Map<String,String> batchProperty=new HashMap<String,String>(1);
  batchProperty.put(PersistenceProperties.KUNDERA_BATCH_SIZE,"String_Node_Str");
  emf=Persistence.createEntityManagerFactory(REDIS_PU,batchProperty);
  EntityManager em=emf.createEntityManager();
  Map<String,Client> clients=(Map<String,Client>)em.getDelegate();
  RedisClient client=(RedisClient)clients.get(REDIS_PU);
  Assert.assertEquals(5,((Batcher)client).getBatchSize());
  final String originalName="String_Node_Str";
  for (int i=0; i < 9; i++) {
    PersonRedis object=new PersonRedis();
    object.setAge(32);
    object.setPersonId(ROW_KEY + i);
    object.setPersonName(originalName);
    em.persist(object);
    if (i >= 5) {
      PersonRedis result=(PersonRedis)client.find(PersonRedis.class,ROW_KEY + i);
      Assert.assertNull(result);
    }
 else     if (i > 0 && i % 4 == 0) {
      PersonRedis result=(PersonRedis)client.find(PersonRedis.class,ROW_KEY + i);
      Assert.assertNotNull(result);
      Assert.assertEquals(result.getPersonId(),object.getPersonId());
      Assert.assertEquals(result.getAge(),object.getAge());
      Assert.assertEquals(result.getPersonName(),object.getPersonName());
    }
  }
  em.flush();
  em.clear();
  em.close();
  em=null;
  emf.close();
  emf=null;
  batchProperty.put(PersistenceProperties.KUNDERA_BATCH_SIZE,null);
  emf=Persistence.createEntityManagerFactory(REDIS_PU,batchProperty);
}
Program: 176651
Project: 176651
Buggy source:
/** 
 * On where clause.
 * @param metadata the metadata
 * @param compoundKeyObject the compound key object
 * @param translator the translator
 * @param queryBuilder the query builder
 * @param compoundKey the compound key
 */
private void onWhereClause(EntityMetadata metadata,Object compoundKeyObject,CQLTranslator translator,StringBuilder queryBuilder,ManagedType compoundKey){
  Field[] fields=metadata.getIdAttribute().getBindableJavaType().getDeclaredFields();
  queryBuilder.append(CQLTranslator.ADD_WHERE_CLAUSE);
  for (  Field field : fields) {
    Attribute attribute=compoundKey.getAttribute(field.getName());
    String columnName=((AbstractAttribute)attribute).getJPAColumnName();
    translator.buildWhereClause(queryBuilder,columnName,field,compoundKeyObject);
  }
  queryBuilder.delete(queryBuilder.lastIndexOf(CQLTranslator.AND_CLAUSE),queryBuilder.length());
}

Fixed version (ground truth):
/** 
 * On where clause.
 * @param metadata the metadata
 * @param compoundKeyObject the compound key object
 * @param translator the translator
 * @param queryBuilder the query builder
 * @param compoundKey the compound key
 */
private void onWhereClause(EntityMetadata metadata,Object compoundKeyObject,CQLTranslator translator,StringBuilder queryBuilder,ManagedType compoundKey){
  Field[] fields=metadata.getIdAttribute().getBindableJavaType().getDeclaredFields();
  queryBuilder.append(CQLTranslator.ADD_WHERE_CLAUSE);
  for (  Field field : fields) {
    if (field != null && !Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers()) && !field.isAnnotationPresent(Transient.class)) {
      Attribute attribute=compoundKey.getAttribute(field.getName());
      String columnName=((AbstractAttribute)attribute).getJPAColumnName();
      translator.buildWhereClause(queryBuilder,columnName,field,compoundKeyObject);
    }
  }
  queryBuilder.delete(queryBuilder.lastIndexOf(CQLTranslator.AND_CLAUSE),queryBuilder.length());
}
Program: 176652
Project: 176652
Buggy source:
/** 
 * Close.
 */
public void close(){
  nodes.clear();
  nodes=null;
  closed=true;
}

Fixed version (ground truth):
/** 
 * Close.
 */
public void close(){
  nodes.clear();
  nodes=null;
  closed=true;
  externalProperties=null;
}
Program: 176653
Project: 176653
Buggy source:
public void clear(){
  if (nodes != null) {
    nodes.clear();
    nodes=null;
    nodes=new ArrayList<Node>();
  }
}

Fixed version (ground truth):
public void clear(){
  if (nodes != null) {
    nodes.clear();
    nodes=null;
    nodes=new ArrayList<Node>();
  }
  externalProperties=null;
}
Program: 176655
Project: 176655
Buggy source:
/** 
 * On query over composite columns.
 * @param m the m
 * @param client the client
 * @param metaModel the meta model
 * @return the list
 */
private List onQueryOverCompositeColumns(EntityMetadata m,Client client,MetamodelImpl metaModel,List<String> relations){
  List<Object> result;
  Class compoundKeyClass=m.getIdAttribute().getBindableJavaType();
  EmbeddableType compoundKey=metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
  String idColumn=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
  StringBuilder builder=new StringBuilder();
  boolean isPresent=false;
  List<String> columns=getColumnList(m,getKunderaQuery().getResult(),compoundKey);
  String selectQuery=columns != null && !columns.isEmpty() ? CQLTranslator.SELECT_QUERY : CQLTranslator.SELECTALL_QUERY;
  CQLTranslator translator=new CQLTranslator();
  selectQuery=StringUtils.replace(selectQuery,CQLTranslator.COLUMN_FAMILY,translator.ensureCase(new StringBuilder(),m.getTableName()).toString());
  builder=appendColumns(builder,columns,selectQuery,translator);
  addWhereClause(builder);
  onCondition(m,metaModel,compoundKey,idColumn,builder,isPresent,translator);
  result=((CassandraClientBase)client).executeQuery(builder.toString(),m.getEntityClazz(),relations);
  return result;
}

Fixed version (ground truth):
/** 
 * On query over composite columns.
 * @param m the m
 * @param client the client
 * @param metaModel the meta model
 * @return the list
 */
private List onQueryOverCompositeColumns(EntityMetadata m,Client client,MetamodelImpl metaModel,List<String> relations){
  List<Object> result=new ArrayList<Object>();
  Class compoundKeyClass=m.getIdAttribute().getBindableJavaType();
  EmbeddableType compoundKey=metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
  String idColumn=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
  StringBuilder builder=new StringBuilder();
  boolean isPresent=false;
  List<String> columns=getColumnList(m,getKunderaQuery().getResult(),compoundKey);
  String selectQuery=columns != null && !columns.isEmpty() ? CQLTranslator.SELECT_QUERY : CQLTranslator.SELECTALL_QUERY;
  CQLTranslator translator=new CQLTranslator();
  selectQuery=StringUtils.replace(selectQuery,CQLTranslator.COLUMN_FAMILY,translator.ensureCase(new StringBuilder(),m.getTableName()).toString());
  builder=appendColumns(builder,columns,selectQuery,translator);
  addWhereClause(builder);
  onCondition(m,metaModel,compoundKey,idColumn,builder,isPresent,translator);
  result=((CassandraClientBase)client).executeQuery(builder.toString(),m.getEntityClazz(),relations);
  return result;
}
Program: 176657
Project: 176657
Buggy source:
/** 
 * Gets the column list.
 * @param m the m
 * @param results the results
 * @return the column list
 */
private List<String> getColumnList(EntityMetadata m,String[] results,EmbeddableType compoundKey){
  List<String> columns=new ArrayList<String>();
  if (results != null && results.length > 0) {
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
    EntityType entity=metaModel.entity(m.getEntityClazz());
    for (int i=1; i < results.length; i++) {
      if (results[i] != null) {
        Attribute col=entity.getAttribute(results[i]);
        if (col == null) {
          throw new QueryHandlerException("String_Node_Str" + results);
        }
 else         if (m.getIdAttribute().equals(col) && compoundKey != null) {
          Field[] fields=m.getIdAttribute().getBindableJavaType().getDeclaredFields();
          for (          Field field : fields) {
            Attribute compositeColumn=compoundKey.getAttribute(field.getName());
            columns.add(((AbstractAttribute)compositeColumn).getJPAColumnName());
          }
        }
 else {
          columns.add(((AbstractAttribute)col).getJPAColumnName());
        }
      }
    }
    return columns;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets the column list.
 * @param m the m
 * @param results the results
 * @return the column list
 */
private List<String> getColumnList(EntityMetadata m,String[] results,EmbeddableType compoundKey){
  List<String> columns=new ArrayList<String>();
  if (results != null && results.length > 0) {
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
    EntityType entity=metaModel.entity(m.getEntityClazz());
    for (int i=1; i < results.length; i++) {
      if (results[i] != null) {
        Attribute col=entity.getAttribute(results[i]);
        if (col == null) {
          throw new QueryHandlerException("String_Node_Str" + results);
        }
 else         if (m.getIdAttribute().equals(col) && compoundKey != null) {
          Field[] fields=m.getIdAttribute().getBindableJavaType().getDeclaredFields();
          for (          Field field : fields) {
            if (!ReflectUtils.isTransientOrStatic(field)) {
              Attribute compositeColumn=compoundKey.getAttribute(field.getName());
              columns.add(((AbstractAttribute)compositeColumn).getJPAColumnName());
            }
          }
        }
 else {
          columns.add(((AbstractAttribute)col).getJPAColumnName());
        }
      }
    }
    return columns;
  }
  return null;
}
Program: 176658
Project: 176658
Buggy source:
public List<EnhanceEntity> readFromIndexTable(EntityMetadata m,Client client,Map<Boolean,List<IndexClause>> indexClauseMap){
  List<SearchResult> searchResults=new ArrayList<SearchResult>();
  List<Object> primaryKeys=new ArrayList<Object>();
  String columnFamilyName=m.getTableName() + Constants.INDEX_TABLE_SUFFIX;
  searchResults=((CassandraClientBase)client).searchInInvertedIndex(columnFamilyName,m,indexClauseMap);
  Map<String,String> embeddedColumns=new HashMap<String,String>();
  for (  SearchResult searchResult : searchResults) {
    if (searchResult.getEmbeddedColumnValues() != null) {
      for (      String embeddedColVal : searchResult.getEmbeddedColumnValues()) {
        if (embeddedColVal != null) {
          StringBuilder strBuilder=new StringBuilder(embeddedColVal);
          strBuilder.append("String_Node_Str");
          strBuilder.append(searchResult.getPrimaryKey().toString());
          embeddedColumns.put(strBuilder.toString(),searchResult.getPrimaryKey().toString());
        }
      }
    }
  }
  List<EnhanceEntity> enhanceEntityList=null;
  if (embeddedColumns != null && !embeddedColumns.isEmpty()) {
    enhanceEntityList=client.find(m.getEntityClazz(),embeddedColumns);
  }
 else {
    for (    SearchResult searchResult : searchResults) {
      primaryKeys.add(searchResult.getPrimaryKey());
    }
    enhanceEntityList=(List<EnhanceEntity>)((CassandraClientBase)client).find(m.getEntityClazz(),m.getRelationNames(),true,m,primaryKeys.toArray(new String[]{}));
  }
  return enhanceEntityList;
}

Fixed version (ground truth):
public List<EnhanceEntity> readFromIndexTable(EntityMetadata m,Client client,Map<Boolean,List<IndexClause>> indexClauseMap){
  List<SearchResult> searchResults=new ArrayList<SearchResult>();
  List<Object> primaryKeys=new ArrayList<Object>();
  String columnFamilyName=m.getTableName() + Constants.INDEX_TABLE_SUFFIX;
  searchResults=((CassandraClientBase)client).searchInInvertedIndex(columnFamilyName,m,indexClauseMap);
  Map<String,String> embeddedColumns=new HashMap<String,String>();
  for (  SearchResult searchResult : searchResults) {
    if (searchResult.getEmbeddedColumnValues() != null) {
      for (      String embeddedColVal : searchResult.getEmbeddedColumnValues()) {
        if (embeddedColVal != null) {
          StringBuilder strBuilder=new StringBuilder(embeddedColVal);
          strBuilder.append("String_Node_Str");
          strBuilder.append(searchResult.getPrimaryKey().toString());
          embeddedColumns.put(strBuilder.toString(),searchResult.getPrimaryKey().toString());
        }
      }
    }
  }
  List<EnhanceEntity> enhanceEntityList=new ArrayList<EnhanceEntity>();
  if (embeddedColumns != null && !embeddedColumns.isEmpty()) {
    enhanceEntityList=client.find(m.getEntityClazz(),embeddedColumns);
  }
 else {
    for (    SearchResult searchResult : searchResults) {
      primaryKeys.add(searchResult.getPrimaryKey());
    }
    enhanceEntityList=(List<EnhanceEntity>)((CassandraClientBase)client).find(m.getEntityClazz(),m.getRelationNames(),true,m,primaryKeys.toArray(new String[]{}));
  }
  return enhanceEntityList;
}
Program: 176664
Project: 176664
Buggy source:
void setImplementor(ResourceManager implementor){
  if (!implementors.contains(implementor)) {
    implementors.add(implementor);
  }
}

Fixed version (ground truth):
void setImplementor(ResourceManager implementor){
  implementors.add(implementor);
}
Program: 176665
Project: 176665
Buggy source:
/** 
 * @param databaseName
 * @param tableName
 * @return
 */
public boolean isCappedCollection(String databaseName,String tableName){
  List<Schema> schemas=getDataStore() != null ? getDataStore().getSchemas() : null;
  if (schemas != null) {
    for (    Schema schema : schemas) {
      if (schema != null && schema.getName() != null && schema.getName().equalsIgnoreCase(databaseName)) {
        for (        Table table : schema.getTables()) {
          if (table.getProperties() != null) {
            return Boolean.parseBoolean(table.getProperties().getProperty(MongoDBConstants.CAPPED));
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param databaseName
 * @param tableName
 * @return
 */
public boolean isCappedCollection(String databaseName,String tableName){
  List<Schema> schemas=getDataStore() != null ? getDataStore().getSchemas() : null;
  if (schemas != null) {
    for (    Schema schema : schemas) {
      if (schema != null && schema.getName() != null && schema.getName().equalsIgnoreCase(databaseName)) {
        for (        Table table : schema.getTables()) {
          if (table.getProperties() != null && tableName.equals(table.getName())) {
            return Boolean.parseBoolean(table.getProperties().getProperty(MongoDBConstants.CAPPED));
          }
        }
      }
    }
  }
  return false;
}
Program: 176666
Project: 176666
Buggy source:
@Test public void testCappedCollection(){
  DBCollection collection=db.getCollection("String_Node_Str");
  Assert.assertTrue(collection.isCapped());
  CommandResult stats=collection.getStats();
  Object maxObj=stats.get(MongoDBConstants.MAX);
  Assert.assertNotNull(maxObj);
  int max=Integer.parseInt(maxObj.toString());
  Assert.assertEquals(10,max);
  List<DBObject> indexInfo=collection.getIndexInfo();
  Assert.assertTrue(indexInfo.isEmpty());
  for (int i=1; i <= max; i++) {
    MongoDBEntitySimple entity=new MongoDBEntitySimple();
    entity.setPersonId(i + "String_Node_Str");
    entity.setPersonName("String_Node_Str" + i);
    entity.setAge((short)i);
    em.persist(entity);
  }
  MongoDBEntitySimple entity=new MongoDBEntitySimple();
  entity.setPersonId((max + 1) + "String_Node_Str");
  entity.setPersonName("String_Node_Str" + (max + 1));
  entity.setAge((short)(max + 1));
  em.persist(entity);
  em.clear();
  MongoDBEntitySimple firstRecord=em.find(MongoDBEntitySimple.class,"String_Node_Str");
  Assert.assertNull(firstRecord);
  MongoDBEntitySimple lastRecord=em.find(MongoDBEntitySimple.class,"String_Node_Str" + (max + 1));
  Assert.assertNotNull(lastRecord);
  em.remove(lastRecord);
  em.clear();
  lastRecord=em.find(MongoDBEntitySimple.class,"String_Node_Str" + (max + 1));
  Assert.assertNotNull(lastRecord);
}

Fixed version (ground truth):
@Test public void testCappedCollection(){
  DBCollection collection=db.getCollection("String_Node_Str");
  Assert.assertTrue(collection.isCapped());
  CommandResult stats=collection.getStats();
  Object maxObj=stats.get(MongoDBConstants.MAX);
  Assert.assertNotNull(maxObj);
  int max=Integer.parseInt(maxObj.toString());
  Assert.assertEquals(10,max);
  List<DBObject> indexInfo=collection.getIndexInfo();
  Assert.assertTrue(indexInfo.isEmpty());
  for (int i=1; i <= max; i++) {
    MongoDBCappedEntity entity=new MongoDBCappedEntity();
    entity.setPersonId(i + "String_Node_Str");
    entity.setPersonName("String_Node_Str" + i);
    entity.setAge((short)i);
    em.persist(entity);
  }
  MongoDBCappedEntity entity=new MongoDBCappedEntity();
  entity.setPersonId((max + 1) + "String_Node_Str");
  entity.setPersonName("String_Node_Str" + (max + 1));
  entity.setAge((short)(max + 1));
  em.persist(entity);
  em.clear();
  MongoDBCappedEntity firstRecord=em.find(MongoDBCappedEntity.class,"String_Node_Str");
  Assert.assertNull(firstRecord);
  MongoDBCappedEntity lastRecord=em.find(MongoDBCappedEntity.class,"String_Node_Str" + (max + 1));
  Assert.assertNotNull(lastRecord);
  em.remove(lastRecord);
  em.clear();
  lastRecord=em.find(MongoDBCappedEntity.class,"String_Node_Str" + (max + 1));
  Assert.assertNotNull(lastRecord);
}
Program: 176667
Project: 176667
Buggy source:
/** 
 * @throws java.lang.Exception
 */
@After public void tearDown() throws Exception {
  truncateMongo();
}

Fixed version (ground truth):
/** 
 * @throws java.lang.Exception
 */
@After public void tearDown() throws Exception {
  truncateMongo();
  emf.close();
}
Program: 176668
Project: 176668
Buggy source:
@Before public void setUp() throws Exception {
  dao=new PersonGISDao(persistenceUnit);
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  KunderaMetadata.INSTANCE.setApplicationMetadata(null);
  dao=new PersonGISDao(persistenceUnit);
}
Program: 176670
Project: 176670
Buggy source:
/** 
 * Fetches(and converts)   {@link Node} instance from Entity object If it's aupdate operation, node is searched and attributes populated Otherwise Node is created into database (replacing any existing node) with attributes populated
 */
public Node getNodeFromEntity(Object entity,GraphDatabaseService graphDb,EntityMetadata m,boolean isUpdate){
  Node node=null;
  Object key=PropertyAccessorHelper.getId(entity,m);
  if (!isUpdate) {
    node=getOrCreateNodeWithUniqueFactory(entity,key,m,graphDb);
  }
 else {
    node=searchNode(key,m,graphDb,true);
  }
  if (node != null) {
    populateNodeProperties(entity,m,node);
  }
  return node;
}

Fixed version (ground truth):
/** 
 * Fetches(and converts)   {@link Node} instance from Entity object If it's aupdate operation, node is searched and attributes populated Otherwise Node is created into database (replacing any existing node) with attributes populated
 * @param id TODO
 */
public Node getNodeFromEntity(Object entity,Object key,GraphDatabaseService graphDb,EntityMetadata m,boolean isUpdate){
  Node node=null;
  if (!isUpdate) {
    node=getOrCreateNodeWithUniqueFactory(entity,key,m,graphDb);
  }
 else {
    node=searchNode(key,m,graphDb,true);
  }
  if (node != null) {
    populateNodeProperties(entity,m,node);
  }
  return node;
}
Program: 176671
Project: 176671
Buggy source:
/** 
 * Converts a given field value to an object that is Neo4J compatible
 * @param source
 * @return
 */
public Object toNeo4JProperty(Object source){
  Class<?> sourceClass=source.getClass();
  if (source instanceof BigDecimal || source instanceof BigInteger) {
    return source.toString();
  }
 else   if ((source instanceof Calendar) || (source instanceof GregorianCalendar)) {
    return PropertyAccessorHelper.fromSourceToTargetClass(String.class,Date.class,((Calendar)source).getTime());
  }
  if (source instanceof Date) {
    return PropertyAccessorHelper.fromSourceToTargetClass(String.class,sourceClass,source);
  }
  return source;
}

Fixed version (ground truth):
/** 
 * Converts a given field value to an object that is Neo4J compatible
 * @param source
 * @return
 */
public Object toNeo4JProperty(Object source){
  if (source instanceof BigDecimal || source instanceof BigInteger) {
    return source.toString();
  }
 else   if ((source instanceof Calendar) || (source instanceof GregorianCalendar)) {
    return PropertyAccessorHelper.fromSourceToTargetClass(String.class,Date.class,((Calendar)source).getTime());
  }
  if (source instanceof Date) {
    Class<?> sourceClass=source.getClass();
    return PropertyAccessorHelper.fromSourceToTargetClass(String.class,sourceClass,source);
  }
  return source;
}
Program: 176673
Project: 176673
Buggy source:
public List<Object> executeLuceneQuery(EntityMetadata m,String luceneQuery){
  log.info("String_Node_Str" + luceneQuery);
  GraphDatabaseService graphDb=getConnection();
  List<Object> entities=new ArrayList<Object>();
  if (!indexer.isNodeAutoIndexingEnabled(graphDb) && m.isIndexable()) {
    Index<Node> nodeIndex=graphDb.index().forNodes(m.getIndexName());
    IndexHits<Node> hits=nodeIndex.query(luceneQuery);
    for (    Node node : hits) {
      if (node != null) {
        entities.add(getEntityWithAssociationFromNode(m,node));
      }
    }
  }
 else {
    IndexHits<Node> hits;
    ReadableIndex<Node> autoNodeIndex=graphDb.index().getNodeAutoIndexer().getAutoIndex();
    hits=autoNodeIndex.query(luceneQuery);
    for (    Node node : hits) {
      entities.add(getEntityWithAssociationFromNode(m,node));
    }
  }
  return entities;
}

Fixed version (ground truth):
public List<Object> executeLuceneQuery(EntityMetadata m,String luceneQuery){
  log.info("String_Node_Str" + luceneQuery);
  GraphDatabaseService graphDb=getConnection();
  List<Object> entities=new ArrayList<Object>();
  if (!indexer.isNodeAutoIndexingEnabled(graphDb) && m.isIndexable()) {
    Index<Node> nodeIndex=graphDb.index().forNodes(m.getIndexName());
    IndexHits<Node> hits=nodeIndex.query(luceneQuery);
    addEntityFromIndexHits(m,entities,hits);
  }
 else {
    ReadableIndex<Node> autoNodeIndex=graphDb.index().getNodeAutoIndexer().getAutoIndex();
    IndexHits<Node> hits=autoNodeIndex.query(luceneQuery);
    addEntityFromIndexHits(m,entities,hits);
  }
  return entities;
}
Program: 176674
Project: 176674
Buggy source:
/** 
 * @param m
 * @param entities
 * @param node
 */
private Object getEntityWithAssociationFromNode(EntityMetadata m,Node node){
  Map<String,Object> relationMap=new HashMap<String,Object>();
  Map<Long,Object> nodeIdToEntityMap=new HashMap<Long,Object>();
  Object entity=mapper.getEntityFromNode(node,m);
  nodeIdToEntityMap.put(node.getId(),entity);
  populateRelations(m,entity,relationMap,node,nodeIdToEntityMap);
  nodeIdToEntityMap.clear();
  if (!relationMap.isEmpty()) {
    return new EnhanceEntity(entity,PropertyAccessorHelper.getId(entity,m),relationMap);
  }
 else {
    return entity;
  }
}

Fixed version (ground truth):
/** 
 * @param m
 * @param entities
 * @param node
 */
private Object getEntityWithAssociationFromNode(EntityMetadata m,Node node){
  Map<String,Object> relationMap=new HashMap<String,Object>();
  Map<Long,Object> nodeIdToEntityMap=new HashMap<Long,Object>();
  Object entity=mapper.getEntityFromNode(node,m);
  nodeIdToEntityMap.put(node.getId(),entity);
  populateRelations(m,entity,relationMap,node,nodeIdToEntityMap);
  nodeIdToEntityMap.clear();
  if (!relationMap.isEmpty() && entity != null) {
    return new EnhanceEntity(entity,PropertyAccessorHelper.getId(entity,m),relationMap);
  }
 else {
    return entity;
  }
}
Program: 176675
Project: 176675
Buggy source:
@Override protected List<Object> recursivelyPopulateEntities(EntityMetadata m,Client client){
  List<Object> entities=new ArrayList<Object>();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  if (appMetadata.isNative(getJPAQuery())) {
    String nativeQuery=appMetadata.getQuery(getJPAQuery());
    Neo4JNativeQuery nativeQueryImpl=Neo4JNativeQueryFactory.getNativeQueryImplementation(queryType);
    entities=nativeQueryImpl.executeNativeQuery(nativeQuery,(Neo4JClient)client,m);
  }
 else {
    String luceneQuery=getLuceneQuery(kunderaQuery);
    entities=((Neo4JClient)client).executeLuceneQuery(m,luceneQuery);
  }
  return entities;
}

Fixed version (ground truth):
@Override protected List<Object> recursivelyPopulateEntities(EntityMetadata m,Client client){
  List<Object> entities=new ArrayList<Object>();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  if (appMetadata.isNative(getJPAQuery())) {
    String nativeQuery=appMetadata.getQuery(getJPAQuery());
    Neo4JNativeQuery nativeQueryImpl=Neo4JNativeQueryFactory.getNativeQueryImplementation(queryType);
    entities=nativeQueryImpl.executeNativeQuery(nativeQuery,(Neo4JClient)client,m);
  }
 else {
    String luceneQuery=getLuceneQuery(kunderaQuery);
    entities=((Neo4JClient)client).executeLuceneQuery(m,luceneQuery);
  }
  return setRelationEntities(entities,client,m);
}
Program: 176676
Project: 176676
Buggy source:
@Override protected EntityReader getReader(){
  return null;
}

Fixed version (ground truth):
@Override protected EntityReader getReader(){
  if (reader == null) {
    reader=new Neo4JEntityReader();
  }
  return reader;
}
Program: 176677
Project: 176677
Buggy source:
/** 
 * Test method for  {@link com.impetus.client.neo4j.GraphEntityMapper#getNodeFromEntity(java.lang.Object,org.neo4j.graphdb.GraphDatabaseService,com.impetus.kundera.metadata.model.EntityMetadata,boolean)}.
 */
@Test public void testGetNodeFromEntity(){
  Actor actor=new Actor();
  actor.setId(1);
  actor.setName("String_Node_Str");
  Transaction tx=graphDb.beginTx();
  Node node=mapper.getNodeFromEntity(actor,graphDb,KunderaMetadataManager.getEntityMetadata(Actor.class),false);
  Assert.assertNotNull(node);
  Assert.assertEquals(1,node.getProperty("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",node.getProperty("String_Node_Str"));
  node.delete();
  tx.success();
  tx.finish();
}

Fixed version (ground truth):
/** 
 * Test method for  {@link com.impetus.client.neo4j.GraphEntityMapper#getNodeFromEntity(java.lang.Object,Object,org.neo4j.graphdb.GraphDatabaseService,com.impetus.kundera.metadata.model.EntityMetadata,boolean)}.
 */
@Test public void testGetNodeFromEntity(){
  Actor actor=new Actor();
  actor.setId(1);
  actor.setName("String_Node_Str");
  Transaction tx=graphDb.beginTx();
  Node node=mapper.getNodeFromEntity(actor,1,graphDb,KunderaMetadataManager.getEntityMetadata(Actor.class),false);
  Assert.assertNotNull(node);
  Assert.assertEquals(1,node.getProperty("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",node.getProperty("String_Node_Str"));
  node.delete();
  tx.success();
  tx.finish();
}
Program: 176678
Project: 176678
Buggy source:
/** 
 * Appends value to builder object for given class type
 * @param builder string builder.
 * @param fieldClazz field class.
 * @param value value to be appended.
 * @param isPresent if field is present.
 * @return true, if value is not null else false.
 */
public boolean appendValue(StringBuilder builder,Class fieldClazz,Object value,boolean isPresent){
  if (value != null) {
    isPresent=true;
    if (fieldClazz.isAssignableFrom(String.class) || isDate(fieldClazz) || fieldClazz.isAssignableFrom(char.class)|| fieldClazz.isAssignableFrom(Character.class)|| fieldClazz.isAssignableFrom(boolean.class)|| fieldClazz.isAssignableFrom(Boolean.class)) {
      builder.append("String_Node_Str");
      if (isDate(fieldClazz)) {
        builder.append(PropertyAccessorFactory.getPropertyAccessor(fieldClazz).toString(value));
      }
 else {
        builder.append(value);
      }
      builder.append("String_Node_Str");
    }
 else {
      builder.append(value);
    }
  }
  return isPresent;
}

Fixed version (ground truth):
/** 
 * Appends value to builder object for given class type
 * @param builder string builder.
 * @param fieldClazz field class.
 * @param value value to be appended.
 * @param isPresent if field is present.
 * @return true, if value is not null else false.
 */
public boolean appendValue(StringBuilder builder,Class fieldClazz,Object value,boolean isPresent){
  if (value != null) {
    isPresent=true;
    if (fieldClazz.isAssignableFrom(String.class) || isDate(fieldClazz) || fieldClazz.isAssignableFrom(char.class)|| fieldClazz.isAssignableFrom(Character.class)) {
      builder.append("String_Node_Str");
      if (isDate(fieldClazz)) {
        builder.append(PropertyAccessorFactory.getPropertyAccessor(fieldClazz).toString(value));
      }
 else {
        builder.append(value);
      }
      builder.append("String_Node_Str");
    }
 else {
      builder.append(value);
    }
  }
  return isPresent;
}
Program: 176680
Project: 176680
Buggy source:
/** 
 * Returns associated bi-directional field.
 * @param originalClazz Original class
 * @param referencedClass Referenced class.
 */
public Field getBiDirectionalField(Class originalClazz,Class referencedClass){
  Field[] fields=referencedClass.getDeclaredFields();
  Class<?> clazzz=null;
  Field biDirectionalField=null;
  for (  Field field : fields) {
    clazzz=field.getType();
    if (PropertyAccessorHelper.isCollection(clazzz)) {
      ParameterizedType type=(ParameterizedType)field.getGenericType();
      Type[] types=type.getActualTypeArguments();
      clazzz=(Class<?>)types[0];
    }
    if (clazzz.equals(originalClazz)) {
      biDirectionalField=field;
      break;
    }
  }
  return biDirectionalField;
}

Fixed version (ground truth):
/** 
 * Returns associated bi-directional field.
 * @param originalClazz Original class
 * @param referencedClass Referenced class.
 */
public Field getBiDirectionalField(Class originalClazz,Class referencedClass){
  Field[] fields=referencedClass.getDeclaredFields();
  Class<?> clazzz=null;
  Field biDirectionalField=null;
  for (  Field field : fields) {
    clazzz=field.getType();
    if (PropertyAccessorHelper.isCollection(clazzz)) {
      ParameterizedType type=(ParameterizedType)field.getGenericType();
      Type[] types=type.getActualTypeArguments();
      clazzz=(Class<?>)types[0];
    }
 else     if (Map.class.isAssignableFrom(clazzz)) {
      ParameterizedType type=(ParameterizedType)field.getGenericType();
      Type[] types=type.getActualTypeArguments();
      clazzz=(Class<?>)types[1];
    }
    if (clazzz.equals(originalClazz)) {
      biDirectionalField=field;
      break;
    }
  }
  return biDirectionalField;
}
Program: 176681
Project: 176681
Buggy source:
/** 
 * Fetches(and converts)   {@link Node} instance from Entity object
 */
public Node fromEntity(Object entity,List<RelationHolder> relations,GraphDatabaseService graphDb,EntityMetadata m,boolean isUpdate){
  Node node=null;
  if (!isUpdate) {
    node=getOrCreateNodeWithUniqueFactory(entity,m,graphDb);
  }
 else {
    Object key=PropertyAccessorHelper.getId(entity,m);
    node=searchNode(key,m,graphDb);
  }
  if (node != null) {
    populateNodeProperties(entity,m,node);
  }
  return node;
}

Fixed version (ground truth):
/** 
 * Fetches(and converts)   {@link Node} instance from Entity object
 */
public Node fromEntity(Object entity,List<RelationHolder> relations,GraphDatabaseService graphDb,EntityMetadata m,boolean isUpdate){
  Node node=null;
  if (!isUpdate) {
    node=getOrCreateNodeWithUniqueFactory(entity,m,graphDb);
  }
 else {
    Object key=PropertyAccessorHelper.getId(entity,m);
    node=searchNode(key,m,graphDb,true);
  }
  if (node != null) {
    populateNodeProperties(entity,m,node);
  }
  return node;
}
Program: 176682
Project: 176682
Buggy source:
/** 
 * Searches a node from the database for a given key
 */
public Node searchNode(Object key,EntityMetadata m,GraphDatabaseService graphDb){
  Node node=null;
  String idColumnName=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
  final MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType())) {
    key=serializeIdAttributeValue(m,key);
  }
  if (indexer.isNodeAutoIndexingEnabled(graphDb)) {
    ReadableIndex<Node> autoNodeIndex=graphDb.index().getNodeAutoIndexer().getAutoIndex();
    IndexHits<Node> nodesFound=autoNodeIndex.get(idColumnName,key);
    if (nodesFound == null || nodesFound.size() == 0 || !nodesFound.hasNext()) {
      return null;
    }
 else {
      node=nodesFound.next();
    }
    nodesFound.close();
  }
 else {
    Index<Node> nodeIndex=graphDb.index().forNodes(m.getIndexName());
    IndexHits<Node> hits=nodeIndex.get(idColumnName,key);
    if (hits == null || hits.size() == 0 || !hits.hasNext()) {
      return null;
    }
 else {
      node=hits.next();
    }
    hits.close();
  }
  return node;
}

Fixed version (ground truth):
/** 
 * Searches a node from the database for a given key
 */
public Node searchNode(Object key,EntityMetadata m,GraphDatabaseService graphDb,boolean skipProxy){
  Node node=null;
  String idColumnName=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
  final MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType())) {
    key=serializeIdAttributeValue(m,key);
  }
  if (indexer.isNodeAutoIndexingEnabled(graphDb)) {
    ReadableIndex<Node> autoNodeIndex=graphDb.index().getNodeAutoIndexer().getAutoIndex();
    IndexHits<Node> nodesFound=autoNodeIndex.get(idColumnName,key);
    if (nodesFound == null || nodesFound.size() == 0 || !nodesFound.hasNext()) {
      return null;
    }
 else {
      if (skipProxy)       node=getNonProxyNode(nodesFound);
 else       node=nodesFound.next();
    }
    nodesFound.close();
  }
 else {
    Index<Node> nodeIndex=graphDb.index().forNodes(m.getIndexName());
    IndexHits<Node> hits=nodeIndex.get(idColumnName,key);
    if (hits == null || hits.size() == 0 || !hits.hasNext()) {
      return null;
    }
 else {
      if (skipProxy)       node=getNonProxyNode(hits);
 else       node=hits.next();
    }
    hits.close();
  }
  return node;
}
Program: 176683
Project: 176683
Buggy source:
@Override public void flush(){
  if (isDirty()) {
    getCurrentNodeState().handleFlush(this);
    this.isProcessed=true;
  }
}

Fixed version (ground truth):
@Override public void flush(){
  if (isDirty()) {
    getCurrentNodeState().handleFlush(this);
    Map<NodeLink,Node> parents=this.getParents();
    Map<NodeLink,Node> children=this.getChildren();
    if (parents != null && !parents.isEmpty()) {
      for (      NodeLink parentNodeLink : parents.keySet()) {
        if (!parentNodeLink.getMultiplicity().equals(ForeignKey.MANY_TO_MANY))         parentNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,this.getEntityId());
      }
    }
    if (children != null && !children.isEmpty()) {
      for (      NodeLink childNodeLink : children.keySet()) {
        if (!childNodeLink.getMultiplicity().equals(ForeignKey.MANY_TO_MANY))         childNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,this.getEntityId());
      }
    }
    this.isProcessed=true;
  }
}
Program: 176684
Project: 176684
Buggy source:
/** 
 * Flushes Dirty objects in   {@link PersistenceCache} to databases.
 */
private void flush(){
  Deque<Node> fs=flushManager.getFlushStack();
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + fs);
  }
  if (fs != null) {
    boolean isBatch=false;
    while (!fs.isEmpty()) {
      Node node=fs.pop();
      if (node.isInState(ManagedState.class) || node.isInState(RemovedState.class)) {
        EntityMetadata metadata=getMetadata(node.getDataClass());
        node.setClient(getClient(metadata));
        if ((node.getClient() instanceof Batcher) && ((Batcher)(node.getClient())).getBatchSize() > 0) {
          isBatch=true;
          ((Batcher)(node.getClient())).addBatch(node);
        }
 else         if (flushMode.equals(FlushModeType.AUTO) || enableFlush) {
          if (isTransactionInProgress && MetadataUtils.defaultTransactionSupported(metadata.getPersistenceUnit())) {
            onSynchronization(node,metadata);
          }
 else {
            node.flush();
          }
        }
        Map<NodeLink,Node> parents=node.getParents();
        Map<NodeLink,Node> children=node.getChildren();
        if (parents != null && !parents.isEmpty()) {
          for (          NodeLink parentNodeLink : parents.keySet()) {
            if (!parentNodeLink.getMultiplicity().equals(ForeignKey.MANY_TO_MANY))             parentNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,node.getEntityId());
          }
        }
        if (children != null && !children.isEmpty()) {
          for (          NodeLink childNodeLink : children.keySet()) {
            if (!childNodeLink.getMultiplicity().equals(ForeignKey.MANY_TO_MANY))             childNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,node.getEntityId());
          }
        }
      }
    }
    if (!isBatch) {
      flushJoinTableData();
    }
  }
}

Fixed version (ground truth):
/** 
 * Flushes Dirty objects in   {@link PersistenceCache} to databases.
 */
private void flush(){
  Deque<Node> fs=flushManager.getFlushStack();
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + fs);
  }
  if (fs != null) {
    boolean isBatch=false;
    while (!fs.isEmpty()) {
      Node node=fs.pop();
      if (node.isInState(ManagedState.class) || node.isInState(RemovedState.class)) {
        EntityMetadata metadata=getMetadata(node.getDataClass());
        node.setClient(getClient(metadata));
        if ((node.getClient() instanceof Batcher) && ((Batcher)(node.getClient())).getBatchSize() > 0) {
          isBatch=true;
          ((Batcher)(node.getClient())).addBatch(node);
        }
 else         if (flushMode.equals(FlushModeType.AUTO) || enableFlush) {
          if (isTransactionInProgress && MetadataUtils.defaultTransactionSupported(metadata.getPersistenceUnit())) {
            onSynchronization(node,metadata);
          }
 else {
            node.flush();
          }
        }
      }
    }
    if (!isBatch) {
      flushJoinTableData();
    }
  }
}
Program: 176686
Project: 176686
Buggy source:
private void validateGeneratedValueAnnotation(final Class<?> clazz,Field field){
  Table table=clazz.getAnnotation(Table.class);
  String schemaName=table.schema();
  schemaName=schemaName.substring(0,schemaName.indexOf('@'));
  GeneratedValue generatedValue=field.getAnnotation(GeneratedValue.class);
  if (generatedValue != null && generatedValue.generator() != null && !generatedValue.generator().isEmpty()) {
    if (!(field.isAnnotationPresent(TableGenerator.class) || field.isAnnotationPresent(SequenceGenerator.class) || clazz.isAnnotationPresent(TableGenerator.class)|| clazz.isAnnotationPresent(SequenceGenerator.class))) {
      throw new IllegalArgumentException("String_Node_Str" + generatedValue.generator());
    }
 else {
      checkForGenerator(clazz,field,generatedValue,schemaName);
    }
  }
}

Fixed version (ground truth):
private void validateGeneratedValueAnnotation(final Class<?> clazz,Field field){
  Table table=clazz.getAnnotation(Table.class);
  String schemaName=table.schema();
  if (schemaName != null && schemaName.indexOf("String_Node_Str") > 0) {
    schemaName=schemaName.substring(0,schemaName.indexOf('@'));
    GeneratedValue generatedValue=field.getAnnotation(GeneratedValue.class);
    if (generatedValue != null && generatedValue.generator() != null && !generatedValue.generator().isEmpty()) {
      if (!(field.isAnnotationPresent(TableGenerator.class) || field.isAnnotationPresent(SequenceGenerator.class) || clazz.isAnnotationPresent(TableGenerator.class)|| clazz.isAnnotationPresent(SequenceGenerator.class))) {
        throw new IllegalArgumentException("String_Node_Str" + generatedValue.generator());
      }
 else {
        checkForGenerator(clazz,field,generatedValue,schemaName);
      }
    }
  }
}
Program: 176688
Project: 176688
Buggy source:
/** 
 * Fetches Non-proxy nodes from index hits
 */
private Node getNonProxyNode(IndexHits<Node> nodesFound){
  Node node=null;
  if (nodesFound.hasNext()) {
    node=nodesFound.next();
  }
 else {
    return null;
  }
  try {
    Object proxyNodeProperty=node.getProperty(PROXY_NODE_TYPE_KEY);
  }
 catch (  NotFoundException e) {
    return node;
  }
  return getNonProxyNode(nodesFound);
}

Fixed version (ground truth):
/** 
 * Fetches Non-proxy nodes from index hits
 */
private Node getNonProxyNode(IndexHits<Node> nodesFound){
  Node node=null;
  if (nodesFound.hasNext()) {
    node=nodesFound.next();
  }
 else {
    return null;
  }
  try {
    Object proxyNodeProperty=node.getProperty(PROXY_NODE_TYPE_KEY);
  }
 catch (  NotFoundException e) {
    return node;
  }
catch (  IllegalStateException e) {
    return node;
  }
  return getNonProxyNode(nodesFound);
}
Program: 176690
Project: 176690
Buggy source:
/** 
 * Deletes an entity from database
 */
@Override public void delete(Object entity,Object key){
  checkActiveTransaction();
  GraphDatabaseService graphDb=getConnection();
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entity.getClass());
  Node node=mapper.searchNode(key,m,graphDb,false);
  if (node != null) {
    if (!((Neo4JTransaction)resource).containsNodeId(node.getId())) {
      node.delete();
      indexer.deleteNodeIndex(m,graphDb,node);
      for (      Relationship relationship : node.getRelationships()) {
        relationship.delete();
        indexer.deleteRelationshipIndex(m,graphDb,relationship);
      }
      ((Neo4JTransaction)resource).addNodeId(node.getId());
    }
  }
 else {
    if (log.isDebugEnabled())     log.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Deletes an entity from database
 */
@Override public void delete(Object entity,Object key){
  checkActiveTransaction();
  GraphDatabaseService graphDb=getConnection();
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entity.getClass());
  Node node=mapper.searchNode(key,m,graphDb,true);
  if (node != null) {
    if (!((Neo4JTransaction)resource).containsNodeId(node.getId())) {
      node.delete();
      indexer.deleteNodeIndex(m,graphDb,node);
      for (      Relationship relationship : node.getRelationships()) {
        relationship.delete();
        indexer.deleteRelationshipIndex(m,graphDb,relationship);
      }
      ((Neo4JTransaction)resource).addNodeId(node.getId());
    }
  }
 else {
    if (log.isDebugEnabled())     log.debug("String_Node_Str");
  }
}