nus-yam/ex-repair huggingface dataset:
Program: 176896
Project: 176896
Buggy source:
@Test public void testCRUD(){
  WebResource webResource=resource();
  if (MediaType.APPLICATION_XML.equals(mediaType)) {
    bookStr1="String_Node_Str";
    bookStr2="String_Node_Str";
    pk1="String_Node_Str";
    pk2="String_Node_Str";
  }
 else   if (MediaType.APPLICATION_JSON.equals(mediaType)) {
    bookStr1="String_Node_Str";
    bookStr2="String_Node_Str";
    pk1="String_Node_Str";
    pk2="String_Node_Str";
  }
 else {
    Assert.fail("String_Node_Str" + mediaType);
    return;
  }
  RESTClient restClient=new RESTClientImpl();
  restClient.initialize(webResource,mediaType);
  applicationToken=restClient.getApplicationToken();
  Assert.assertNotNull(applicationToken);
  Assert.assertTrue(applicationToken.startsWith("String_Node_Str"));
  sessionToken=restClient.getSessionToken(applicationToken);
  Assert.assertNotNull(sessionToken);
  Assert.assertTrue(applicationToken.startsWith("String_Node_Str"));
  restClient.insertBook(sessionToken,bookStr1);
  restClient.insertBook(sessionToken,bookStr2);
  String foundBook=restClient.findBook(sessionToken,pk1);
  Assert.assertNotNull(foundBook);
  if (MediaType.APPLICATION_JSON.equals(mediaType)) {
    foundBook="String_Node_Str" + foundBook + "String_Node_Str";
  }
  String updatedBook=restClient.updateBook(sessionToken,foundBook);
  Assert.assertNotNull(updatedBook);
  restClient.deleteBook(sessionToken,updatedBook,pk1);
  restClient.deleteBook(sessionToken,updatedBook,pk2);
  restClient.closeSession(sessionToken);
  restClient.closeApplication(applicationToken);
}

Fixed version (ground truth):
@Test public void testCRUD(){
  WebResource webResource=resource();
  if (MediaType.APPLICATION_XML.equals(mediaType)) {
    bookStr1="String_Node_Str";
    bookStr2="String_Node_Str";
    pk1="String_Node_Str";
    pk2="String_Node_Str";
  }
 else   if (MediaType.APPLICATION_JSON.equals(mediaType)) {
    bookStr1="String_Node_Str";
    bookStr2="String_Node_Str";
    pk1="String_Node_Str";
    pk2="String_Node_Str";
  }
 else {
    Assert.fail("String_Node_Str" + mediaType);
    return;
  }
  RESTClient restClient=new RESTClientImpl();
  restClient.initialize(webResource,mediaType);
  applicationToken=restClient.getApplicationToken();
  Assert.assertNotNull(applicationToken);
  Assert.assertTrue(applicationToken.startsWith("String_Node_Str"));
  sessionToken=restClient.getSessionToken(applicationToken);
  Assert.assertNotNull(sessionToken);
  Assert.assertTrue(sessionToken.startsWith("String_Node_Str"));
  restClient.insertBook(sessionToken,bookStr1);
  restClient.insertBook(sessionToken,bookStr2);
  String foundBook=restClient.findBook(sessionToken,pk1);
  Assert.assertNotNull(foundBook);
  if (MediaType.APPLICATION_JSON.equals(mediaType)) {
    foundBook="String_Node_Str" + foundBook + "String_Node_Str";
  }
  String updatedBook=restClient.updateBook(sessionToken,foundBook);
  Assert.assertNotNull(updatedBook);
  restClient.deleteBook(sessionToken,updatedBook,pk1);
  restClient.deleteBook(sessionToken,updatedBook,pk2);
  restClient.closeSession(sessionToken);
  restClient.closeApplication(applicationToken);
}
Program: 176898
Project: 176898
Buggy source:
/** 
 * Instantiates a new lucene indexer.
 * @param analyzer the analyzer
 * @param lucDirPath the luc dir path
 */
private LuceneIndexer(Analyzer analyzer,String lucDirPath){
  super(analyzer);
  try {
    luceneDirPath=lucDirPath;
    index=new RAMDirectory();
    w=new IndexWriter(index,new IndexWriterConfig(Version.LUCENE_34,analyzer));
    w.setMergePolicy(new LogDocMergePolicy());
    w.setMergeFactor(1000);
    w.getConfig().setRAMBufferSizeMB(32);
  }
 catch (  CorruptIndexException e) {
    throw new LuceneIndexingException(e);
  }
catch (  LockObtainFailedException e) {
    throw new LuceneIndexingException(e);
  }
catch (  IOException e) {
    throw new LuceneIndexingException(e);
  }
}

Fixed version (ground truth):
/** 
 * Instantiates a new lucene indexer.
 * @param analyzer the analyzer
 * @param lucDirPath the luc dir path
 */
private LuceneIndexer(Analyzer analyzer,String lucDirPath){
  super(analyzer);
  try {
    luceneDirPath=lucDirPath;
    File file=new File(luceneDirPath);
    if (file.exists()) {
      Directory sourceDir=FSDirectory.open(getIndexDirectory());
      index=new RAMDirectory(sourceDir);
    }
 else {
      index=new RAMDirectory();
    }
    w=new IndexWriter(index,new IndexWriterConfig(Version.LUCENE_34,analyzer));
    w.setMergePolicy(new LogDocMergePolicy());
    w.setMergeFactor(1000);
    w.getConfig().setRAMBufferSizeMB(32);
  }
 catch (  CorruptIndexException e) {
    throw new LuceneIndexingException(e);
  }
catch (  LockObtainFailedException e) {
    throw new LuceneIndexingException(e);
  }
catch (  IOException e) {
    throw new LuceneIndexingException(e);
  }
}
Program: 176899
Project: 176899
Buggy source:
@Override public final void persist(Object e){
  checkClosed();
  checkTransactionNeeded();
  if (e == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    getPersistenceDelegator().persist(e);
  }
 catch (  Exception ex) {
    getPersistenceDelegator().rollback();
    throw new KunderaException(ex);
  }
}

Fixed version (ground truth):
@Override public final void persist(Object e){
  checkClosed();
  checkTransactionNeeded();
  if (e == null) {
    getPersistenceDelegator().rollback();
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    getPersistenceDelegator().persist(e);
  }
 catch (  Exception ex) {
    getPersistenceDelegator().rollback();
    throw new KunderaException(ex);
  }
}
Program: 176900
Project: 176900
Buggy source:
@Override public void handleFind(NodeStateContext nodeStateContext){
  Client client=nodeStateContext.getClient();
  Class<?> nodeDataClass=nodeStateContext.getDataClass();
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(nodeDataClass);
  String entityId=ObjectGraphUtils.getEntityId(nodeStateContext.getNodeId());
  Object nodeData=null;
  EntityReader reader=client.getReader();
  EnhanceEntity ee=reader.findById(entityId,entityMetadata,client);
  if (ee != null && ee.getEntity() != null) {
    Object entity=ee.getEntity();
    if ((entityMetadata.getRelationNames() == null || entityMetadata.getRelationNames().isEmpty()) && !entityMetadata.isRelationViaJoinTable()) {
      nodeData=entity;
      nodeStateContext.setData(nodeData);
      nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
      nodeStateContext.setDirty(false);
      Object original=((Node)nodeStateContext).clone();
      ((Node)nodeStateContext).setOriginalNode((Node)original);
      return;
    }
 else {
      nodeData=reader.recursivelyFindEntities(ee.getEntity(),ee.getRelations(),entityMetadata,nodeStateContext.getPersistenceDelegator());
    }
  }
  if (nodeData != null) {
    nodeStateContext.setData(nodeData);
    nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
    nodeStateContext.setDirty(false);
    Object original=ObjectUtils.deepCopy((Node)nodeStateContext);
    ((Node)nodeStateContext).setOriginalNode((Node)original);
  }
}

Fixed version (ground truth):
@Override public void handleFind(NodeStateContext nodeStateContext){
  Client client=nodeStateContext.getClient();
  Class<?> nodeDataClass=nodeStateContext.getDataClass();
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(nodeDataClass);
  String entityId=ObjectGraphUtils.getEntityId(nodeStateContext.getNodeId());
  Object nodeData=null;
  EntityReader reader=client.getReader();
  EnhanceEntity ee=reader.findById(entityId,entityMetadata,client);
  if (ee != null && ee.getEntity() != null) {
    Object entity=ee.getEntity();
    if ((entityMetadata.getRelationNames() == null || entityMetadata.getRelationNames().isEmpty()) && !entityMetadata.isRelationViaJoinTable()) {
      nodeData=entity;
      nodeStateContext.setData(nodeData);
      nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
      nodeStateContext.setDirty(false);
      Object original=((Node)nodeStateContext).clone();
      ((Node)nodeStateContext).setOriginalNode((Node)original);
      return;
    }
 else {
      nodeData=reader.recursivelyFindEntities(ee.getEntity(),ee.getRelations(),entityMetadata,nodeStateContext.getPersistenceDelegator());
    }
  }
  if (nodeData != null) {
    nodeStateContext.setData(nodeData);
    nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
    nodeStateContext.setDirty(false);
    Object original=((Node)nodeStateContext).clone();
    ((Node)nodeStateContext).setOriginalNode((Node)original);
  }
}
Program: 176902
Project: 176902
Buggy source:
@Override protected void onPersist(EntityMetadata metadata,Object entity,Object id,List<RelationHolder> rlHolders){
  PelopsDataHandler.ThriftRow tf=null;
  try {
    tf=populateTfRow(entity,id.toString(),metadata);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new KunderaException(e);
  }
  addRelationsToThriftRow(metadata,tf,rlHolders);
  Mutator mutator=Pelops.createMutator(PelopsUtils.generatePoolName(getPersistenceUnit()));
  List<Column> thriftColumns=tf.getColumns();
  List<SuperColumn> thriftSuperColumns=tf.getSuperColumns();
  if (thriftColumns != null && !thriftColumns.isEmpty()) {
    mutator.writeColumns(metadata.getTableName(),new Bytes(tf.getId().getBytes()),Arrays.asList(tf.getColumns().toArray(new Column[0])));
  }
  if (thriftSuperColumns != null && !thriftSuperColumns.isEmpty()) {
    for (    SuperColumn sc : thriftSuperColumns) {
      mutator.writeSubColumns(metadata.getTableName(),tf.getId(),Bytes.toUTF8(sc.getName()),sc.getColumns());
    }
  }
  mutator.execute(ConsistencyLevel.ONE);
  tf=null;
}

Fixed version (ground truth):
@Override protected void onPersist(EntityMetadata metadata,Object entity,Object id,List<RelationHolder> rlHolders){
  PelopsDataHandler.ThriftRow tf=null;
  try {
    tf=populateTfRow(entity,id.toString(),metadata);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new KunderaException(e);
  }
  addRelationsToThriftRow(metadata,tf,rlHolders);
  Mutator mutator=Pelops.createMutator(PelopsUtils.generatePoolName(getPersistenceUnit()));
  List<Column> thriftColumns=tf.getColumns();
  List<SuperColumn> thriftSuperColumns=tf.getSuperColumns();
  if (thriftColumns != null && !thriftColumns.isEmpty()) {
    mutator.writeColumns(metadata.getTableName(),Bytes.fromUTF8(tf.getId()),Arrays.asList(tf.getColumns().toArray(new Column[0])));
  }
  if (thriftSuperColumns != null && !thriftSuperColumns.isEmpty()) {
    for (    SuperColumn sc : thriftSuperColumns) {
      mutator.writeSubColumns(metadata.getTableName(),tf.getId(),Bytes.toUTF8(sc.getName()),sc.getColumns());
    }
  }
  mutator.execute(ConsistencyLevel.ONE);
  tf=null;
}
Program: 176903
Project: 176903
Buggy source:
@Override public <E>List<E> getColumnsById(String joinTableName,String joinColumnName,String inverseJoinColumnName,String parentId){
  Selector selector=Pelops.createSelector(PelopsUtils.generatePoolName(getPersistenceUnit()));
  List<Column> columns=selector.getColumnsFromRow(joinTableName,new Bytes(parentId.getBytes()),Selector.newColumnsPredicateAll(true,10),ConsistencyLevel.ONE);
  List<E> foreignKeys=handler.getForeignKeysFromJoinTable(inverseJoinColumnName,columns);
  return foreignKeys;
}

Fixed version (ground truth):
@Override public <E>List<E> getColumnsById(String joinTableName,String joinColumnName,String inverseJoinColumnName,String parentId){
  Selector selector=Pelops.createSelector(PelopsUtils.generatePoolName(getPersistenceUnit()));
  List<Column> columns=selector.getColumnsFromRow(joinTableName,Bytes.fromUTF8(parentId),Selector.newColumnsPredicateAll(true,10),ConsistencyLevel.ONE);
  List<E> foreignKeys=handler.getForeignKeysFromJoinTable(inverseJoinColumnName,columns);
  return foreignKeys;
}
Program: 176904
Project: 176904
Buggy source:
/** 
 * Persists records into Join Table
 */
public void persistJoinTable(JoinTableData joinTableData){
  String poolName=PelopsUtils.generatePoolName(getPersistenceUnit());
  Mutator mutator=Pelops.createMutator(poolName);
  String joinTableName=joinTableData.getJoinTableName();
  String invJoinColumnName=joinTableData.getInverseJoinColumnName();
  Map<Object,Set<Object>> joinTableRecords=joinTableData.getJoinTableRecords();
  for (  Object key : joinTableRecords.keySet()) {
    Set<Object> values=joinTableRecords.get(key);
    List<Column> columns=new ArrayList<Column>();
    for (    Object value : values) {
      Column column=new Column();
      column.setName(PropertyAccessorFactory.STRING.toBytes(invJoinColumnName + "String_Node_Str" + (String)value));
      column.setValue(PropertyAccessorFactory.STRING.toBytes((String)value));
      column.setTimestamp(System.currentTimeMillis());
      columns.add(column);
    }
    createIndexesOnColumns(joinTableName,poolName,columns);
    String pk=(String)key;
    mutator.writeColumns(joinTableName,new Bytes(pk.getBytes()),Arrays.asList(columns.toArray(new Column[0])));
    mutator.execute(ConsistencyLevel.ONE);
  }
}

Fixed version (ground truth):
/** 
 * Persists records into Join Table
 */
public void persistJoinTable(JoinTableData joinTableData){
  String poolName=PelopsUtils.generatePoolName(getPersistenceUnit());
  Mutator mutator=Pelops.createMutator(poolName);
  String joinTableName=joinTableData.getJoinTableName();
  String invJoinColumnName=joinTableData.getInverseJoinColumnName();
  Map<Object,Set<Object>> joinTableRecords=joinTableData.getJoinTableRecords();
  for (  Object key : joinTableRecords.keySet()) {
    Set<Object> values=joinTableRecords.get(key);
    List<Column> columns=new ArrayList<Column>();
    for (    Object value : values) {
      Column column=new Column();
      column.setName(PropertyAccessorFactory.STRING.toBytes(invJoinColumnName + "String_Node_Str" + (String)value));
      column.setValue(PropertyAccessorFactory.STRING.toBytes((String)value));
      column.setTimestamp(System.currentTimeMillis());
      columns.add(column);
    }
    createIndexesOnColumns(joinTableName,poolName,columns);
    String pk=(String)key;
    mutator.writeColumns(joinTableName,Bytes.fromUTF8(pk),Arrays.asList(columns.toArray(new Column[0])));
    mutator.execute(ConsistencyLevel.ONE);
  }
}
Program: 176906
Project: 176906
Buggy source:
/** 
 * Retrieves an entity from ID
 * @param primaryKey
 * @param m
 * @param client
 * @return
 */
protected EnhanceEntity findById(Object primaryKey,EntityMetadata m,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),primaryKey);
    if (o == null) {
      return null;
    }
 else {
      return o instanceof EnhanceEntity ? (EnhanceEntity)o : new EnhanceEntity(o,getId(o,m),null);
    }
  }
 catch (  Exception e) {
    throw new PersistenceException(e);
  }
}

Fixed version (ground truth):
/** 
 * Retrieves an entity from ID
 * @param primaryKey
 * @param m
 * @param client
 * @return
 */
protected EnhanceEntity findById(Object primaryKey,EntityMetadata m,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),primaryKey);
    if (o == null) {
      return null;
    }
 else {
      return o instanceof EnhanceEntity ? (EnhanceEntity)o : new EnhanceEntity(o,getId(o,m),null);
    }
  }
 catch (  Exception e) {
    throw new EntityReaderException(e);
  }
}
Program: 176907
Project: 176907
Buggy source:
/** 
 * Recursively fetches child entities for a given <code>entity</code>
 * @param entity
 * @param relationsMap
 * @param client
 * @param m
 * @param pd
 * @return
 */
public Object recursivelyFindEntities(Object entity,Map<String,Object> relationsMap,EntityMetadata m,PersistenceDelegator pd){
  String entityId=PropertyAccessorHelper.getId(entity,m);
  associationBuilder=new AssociationBuilder();
  for (  Relation relation : m.getRelations()) {
    if (relation.isRelatedViaJoinTable()) {
      PersistenceCacheManager.addEntityToPersistenceCache(entity,pd,entityId);
      associationBuilder.populateRelationFromJoinTable(entity,m,pd,relation);
    }
 else {
      String relationName=MetadataUtils.getMappedName(m,relation);
      Object relationValue=relationsMap != null ? relationsMap.get(relationName) : null;
      Class<?> childClass=relation.getTargetEntity();
      EntityMetadata childMetadata=KunderaMetadataManager.getEntityMetadata(childClass);
      if (relationValue != null) {
        associationBuilder.populateRelationFromValue(entity,pd,relation,relationValue,childMetadata);
      }
 else {
        associationBuilder.populateRelationViaQuery(entity,pd,entityId,relation,relationName,childMetadata);
      }
    }
  }
  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
 */
public Object recursivelyFindEntities(Object entity,Map<String,Object> relationsMap,EntityMetadata m,PersistenceDelegator pd){
  String entityId=PropertyAccessorHelper.getId(entity,m);
  associationBuilder=new AssociationBuilder();
  for (  Relation relation : m.getRelations()) {
    if (relation.isRelatedViaJoinTable()) {
      PersistenceCacheManager.addEntityToPersistenceCache(entity,pd,entityId);
      associationBuilder.populateRelationFromJoinTable(entity,m,pd,relation);
    }
 else {
      String relationName=MetadataUtils.getMappedName(m,relation);
      Object relationValue=relationsMap != null ? relationsMap.get(relationName) : null;
      Class<?> childClass=relation.getTargetEntity();
      EntityMetadata childMetadata=KunderaMetadataManager.getEntityMetadata(childClass);
      if (relationValue != null) {
        associationBuilder.populateRelationFromValue(entity,pd,relation,relationValue,childMetadata);
      }
 else {
        associationBuilder.populateRelationViaQuery(entity,pd,entityId,relation,relationName,childMetadata);
      }
    }
  }
  return entity;
}
Program: 176909
Project: 176909
Buggy source:
/** 
 * @param entity
 * @param pd
 * @param relation
 * @param relationValue
 */
void populateRelationFromValue(Object entity,PersistenceDelegator pd,Relation relation,Object relationValue,EntityMetadata childMetadata){
  Class<?> childClass=relation.getTargetEntity();
  Object child=pd.find(childClass,relationValue.toString());
  child=child != null && child instanceof EnhanceEntity ? ((EnhanceEntity)child).getEntity() : child;
  PropertyAccessorHelper.set(entity,relation.getProperty(),child);
  Field biDirectionalField=getBiDirectionalField(entity.getClass(),relation.getTargetEntity());
  boolean isBidirectionalRelation=(biDirectionalField != null);
  if (isBidirectionalRelation) {
    Relation reverseRelation=childMetadata.getRelation(biDirectionalField.getName());
    String childId=PropertyAccessorHelper.getId(child,childMetadata);
    EntityMetadata reverseEntityMetadata=KunderaMetadataManager.getEntityMetadata(entity.getClass());
    populateRelationViaQuery(child,pd,childId,reverseRelation,relation.getJoinColumnName(),reverseEntityMetadata);
  }
}

Fixed version (ground truth):
/** 
 * @param entity
 * @param pd
 * @param relation
 * @param relationValue
 */
void populateRelationFromValue(Object entity,PersistenceDelegator pd,Relation relation,Object relationValue,EntityMetadata childMetadata){
  Class<?> childClass=relation.getTargetEntity();
  Object child=pd.find(childClass,relationValue.toString());
  child=child != null && child instanceof EnhanceEntity ? ((EnhanceEntity)child).getEntity() : child;
  if (child != null) {
    PropertyAccessorHelper.set(entity,relation.getProperty(),child);
    Field biDirectionalField=getBiDirectionalField(entity.getClass(),relation.getTargetEntity());
    boolean isBidirectionalRelation=(biDirectionalField != null);
    if (isBidirectionalRelation) {
      Relation reverseRelation=childMetadata.getRelation(biDirectionalField.getName());
      String childId=PropertyAccessorHelper.getId(child,childMetadata);
      EntityMetadata reverseEntityMetadata=KunderaMetadataManager.getEntityMetadata(entity.getClass());
      populateRelationViaQuery(child,pd,childId,reverseRelation,relation.getJoinColumnName(),reverseEntityMetadata);
    }
  }
}
Program: 176910
Project: 176910
Buggy source:
/** 
 * Writes an entity into Persistence cache
 */
public void persist(Object e){
  EntityMetadata metadata=getMetadata(e.getClass());
  getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState(),getPersistenceCache());
  Node headNode=graph.getHeadNode();
  if (headNode.getParents() == null) {
    headNode.setHeadNode(true);
    getPersistenceCache().getMainCache().addHeadNode(headNode);
  }
  headNode.persist();
  flush();
  graph.getNodeMapping().clear();
  graph=null;
  getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  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){
  EntityMetadata metadata=getMetadata(e.getClass());
  getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState(),getPersistenceCache());
  Node headNode=graph.getHeadNode();
  if (headNode.getParents() == null) {
    headNode.setHeadNode(true);
    getPersistenceCache().getMainCache().addHeadNode(headNode);
  }
  headNode.persist();
  flush();
  graph.getNodeMapping().clear();
  graph=null;
  getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  log.debug("String_Node_Str" + e.getClass());
}
Program: 176911
Project: 176911
Buggy source:
@Override void startServer(){
  if (!cli.isStarted()) {
    cli.startCluster();
  }
}

Fixed version (ground truth):
@Override void startServer(){
}
Program: 176912
Project: 176912
Buggy source:
@Override void stopServer(){
  if (cli.isStarted()) {
    cli.stopCluster();
  }
}

Fixed version (ground truth):
@Override void stopServer(){
}
Program: 176913
Project: 176913
Buggy source:
@Override protected void setUp() throws Exception {
  setUpInternal("String_Node_Str");
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
}
Program: 176914
Project: 176914
Buggy source:
@Override protected void tearDown() throws Exception {
  tearDownInternal();
}

Fixed version (ground truth):
@Override protected void tearDown() throws Exception {
}
Program: 176916
Project: 176916
Buggy source:
/** 
 * Inits the filter.
 */
private void initFilter(){
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  String indexName=metadata.getIndexName();
  if (null == filter) {
    return;
  }
  List<String> clauses=tokenize(filter,INTER_CLAUSE_PATTERN);
  clauses=parseFilterForBetweenClause(clauses,indexName);
  boolean newClause=true;
  for (  String clause : clauses) {
    if (newClause) {
      List<String> tokens=tokenize(clause,INTRA_CLAUSE_PATTERN);
      if (tokens.size() != 3) {
        throw new PersistenceException("String_Node_Str" + clause);
      }
      String property=tokens.get(0);
      property=property.substring((entityAlias + "String_Node_Str").length());
      property=indexName + "String_Node_Str" + property;
      String condition=tokens.get(1);
      if (!Arrays.asList(INTRA_CLAUSE_OPERATORS).contains(condition.toUpperCase())) {
        throw new JPQLParseException("String_Node_Str" + clause);
      }
      filtersQueue.add(new FilterClause(property,condition,tokens.get(2)));
      newClause=false;
    }
 else {
      if (Arrays.asList(INTER_CLAUSE_OPERATORS).contains(clause.toUpperCase())) {
        filtersQueue.add(clause.toUpperCase());
        newClause=true;
      }
 else {
        throw new JPQLParseException("String_Node_Str" + clause);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Inits the filter.
 */
private void initFilter(){
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  String indexName=metadata.getIndexName();
  if (null == filter) {
    return;
  }
  List<String> clauses=tokenize(filter,INTER_CLAUSE_PATTERN);
  clauses=parseFilterForBetweenClause(clauses,indexName);
  boolean newClause=true;
  for (  String clause : clauses) {
    if (newClause) {
      List<String> tokens=tokenize(clause,INTRA_CLAUSE_PATTERN);
      if (tokens.size() != 3) {
        throw new PersistenceException("String_Node_Str" + clause);
      }
      String property=tokens.get(0);
      property=property.substring((entityAlias + "String_Node_Str").length());
      String columnName=getColumnNameFromFieldName(metadata,property);
      columnName=indexName + "String_Node_Str" + columnName;
      String condition=tokens.get(1);
      if (!Arrays.asList(INTRA_CLAUSE_OPERATORS).contains(condition.toUpperCase())) {
        throw new JPQLParseException("String_Node_Str" + clause);
      }
      filtersQueue.add(new FilterClause(columnName,condition,tokens.get(2)));
      newClause=false;
    }
 else {
      if (Arrays.asList(INTER_CLAUSE_OPERATORS).contains(clause.toUpperCase())) {
        filtersQueue.add(clause.toUpperCase());
        newClause=true;
      }
 else {
        throw new JPQLParseException("String_Node_Str" + clause);
      }
    }
  }
}
Program: 176919
Project: 176919
Buggy source:
/** 
 * Inits the client.
 * @throws TTransportException the t transport exception
 */
private static void initClient() throws TTransportException {
  TSocket socket=new TSocket("String_Node_Str",9160);
  TTransport transport=new TFramedTransport(socket);
  TProtocol protocol=new TBinaryProtocol(transport);
  client=new Cassandra.Client(protocol);
  socket.open();
}

Fixed version (ground truth):
/** 
 * Inits the client.
 * @throws TTransportException the t transport exception
 */
public static void initClient() throws TTransportException {
  TSocket socket=new TSocket("String_Node_Str",9160);
  TTransport transport=new TFramedTransport(socket);
  TProtocol protocol=new TBinaryProtocol(transport);
  client=new Cassandra.Client(protocol);
  socket.open();
}
Program: 176920
Project: 176920
Buggy source:
private Map<LinkProperty,Object> getLinkProperties(Relation relation){
  Map<LinkProperty,Object> linkProperties=new HashMap<NodeLink.LinkProperty,Object>();
  linkProperties.put(LinkProperty.LINK_NAME,MetadataUtils.getMappedName(relation));
  linkProperties.put(LinkProperty.IS_SHARED_BY_PRIMARY_KEY,relation.isJoinedByPrimaryKey());
  linkProperties.put(LinkProperty.IS_BIDIRECTIONAL,!relation.isUnary());
  linkProperties.put(LinkProperty.IS_RELATED_VIA_JOIN_TABLE,relation.isRelatedViaJoinTable());
  linkProperties.put(LinkProperty.PROPERTY,relation.getProperty());
  linkProperties.put(LinkProperty.CASCADE,relation.getCascades());
  if (relation.isRelatedViaJoinTable()) {
    linkProperties.put(LinkProperty.JOIN_TABLE_METADATA,relation.getJoinTableMetadata());
  }
  return linkProperties;
}

Fixed version (ground truth):
/** 
 * @param metadata Entity metadata of the parent node
 * @param relation 
 * @return
 */
private Map<LinkProperty,Object> getLinkProperties(EntityMetadata metadata,Relation relation){
  Map<LinkProperty,Object> linkProperties=new HashMap<NodeLink.LinkProperty,Object>();
  linkProperties.put(LinkProperty.LINK_NAME,MetadataUtils.getMappedName(metadata,relation));
  linkProperties.put(LinkProperty.IS_SHARED_BY_PRIMARY_KEY,relation.isJoinedByPrimaryKey());
  linkProperties.put(LinkProperty.IS_BIDIRECTIONAL,!relation.isUnary());
  linkProperties.put(LinkProperty.IS_RELATED_VIA_JOIN_TABLE,relation.isRelatedViaJoinTable());
  linkProperties.put(LinkProperty.PROPERTY,relation.getProperty());
  linkProperties.put(LinkProperty.CASCADE,relation.getCascades());
  if (relation.isRelatedViaJoinTable()) {
    linkProperties.put(LinkProperty.JOIN_TABLE_METADATA,relation.getJoinTableMetadata());
  }
  return linkProperties;
}
Program: 176921
Project: 176921
Buggy source:
/** 
 * @param graph
 * @param node
 * @param relation
 * @param childObject
 */
private void addChildNodesToGraph(ObjectGraph graph,Node node,Relation relation,Object childObject,NodeState initialNodeState){
  Node childNode=getNode(childObject,graph,initialNodeState);
  if (childNode != null) {
    NodeLink nodeLink=new NodeLink(node.getNodeId(),childNode.getNodeId());
    nodeLink.setMultiplicity(relation.getType());
    nodeLink.setLinkProperties(getLinkProperties(relation));
    childNode.addParentNode(nodeLink,node);
    node.addChildNode(nodeLink,childNode);
  }
}

Fixed version (ground truth):
/** 
 * @param graph
 * @param node
 * @param relation
 * @param childObject
 */
private void addChildNodesToGraph(ObjectGraph graph,Node node,Relation relation,Object childObject,NodeState initialNodeState){
  Node childNode=getNode(childObject,graph,initialNodeState);
  if (childNode != null) {
    NodeLink nodeLink=new NodeLink(node.getNodeId(),childNode.getNodeId());
    nodeLink.setMultiplicity(relation.getType());
    EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
    nodeLink.setLinkProperties(getLinkProperties(metadata,relation));
    childNode.addParentNode(nodeLink,node);
    node.addChildNode(nodeLink,childNode);
  }
}
Program: 176922
Project: 176922
Buggy source:
/** 
 * Returns mapped relational name, in case of bi directional mapping, it will return back pKey name of associated entity.
 * @param relation holding relation.
 * @return   mapped/join column name.
 */
public static String getMappedName(Relation relation){
  String joinColumn=relation.getJoinColumnName();
  if (joinColumn == null) {
    Class clazz=relation.getTargetEntity();
    EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(clazz);
    joinColumn=metadata.getIdColumn().getName();
  }
  return joinColumn;
}

Fixed version (ground truth):
/** 
 * Returns mapped relational name, in case of bi directional mapping, it will return back pKey name of associated entity.
 * @param relation holding relation.
 * @return   mapped/join column name.
 */
public static String getMappedName(EntityMetadata parentMetadata,Relation relation){
  String joinColumn=relation.getJoinColumnName();
  if (joinColumn == null) {
    Class clazz=relation.getTargetEntity();
    EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(clazz);
    joinColumn=relation.getType().equals(ForeignKey.ONE_TO_MANY) ? parentMetadata.getIdColumn().getName() : metadata.getIdColumn().getName();
  }
  return joinColumn;
}
Program: 176923
Project: 176923
Buggy source:
/** 
 * Gets the element collection object name.
 * @param rowKey the row key
 * @param elementCollectionObject the element collection object
 * @return the element collection object name
 */
public String getElementCollectionObjectName(String rowKey,Object elementCollectionObject){
  if (getElementCollectionCache().get(rowKey) == null) {
    log.debug("String_Node_Str" + rowKey);
    return null;
  }
 else {
    Map<Object,String> elementCollectionObjectMap=getElementCollectionCache().get(rowKey);
    String elementCollectionObjectName=elementCollectionObjectMap.get(elementCollectionObject);
    if (elementCollectionObjectName == null) {
      log.debug("String_Node_Str" + elementCollectionObject);
      return null;
    }
 else {
      return elementCollectionObjectName;
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets the element collection object name.
 * @param rowKey the row key
 * @param elementCollectionObject the element collection object
 * @return the element collection object name
 */
public String getElementCollectionObjectName(String rowKey,Object elementCollectionObject){
  if (getElementCollectionCache().get(rowKey) == null) {
    log.debug("String_Node_Str" + rowKey);
    return null;
  }
 else {
    Map<Object,String> elementCollectionObjectMap=getElementCollectionCache().get(rowKey);
    String elementCollectionObjectName=elementCollectionObjectMap.get(elementCollectionObject);
    if (elementCollectionObjectName == null) {
      for (      Object obj : elementCollectionObjectMap.keySet()) {
        if (DeepEquals.deepEquals(elementCollectionObject,obj)) {
          elementCollectionObjectName=elementCollectionObjectMap.get(obj);
          break;
        }
      }
    }
    if (elementCollectionObjectName == null) {
      log.debug("String_Node_Str" + elementCollectionObject);
      return null;
    }
 else {
      return elementCollectionObjectName;
    }
  }
}
Program: 176924
Project: 176924
Buggy source:
public ObjectGraph getObjectGraph(Object entity,NodeState initialNodeState,PersistenceCache persistenceCache){
  ObjectGraph objectGraph=new ObjectGraph();
  this.persistenceCache=persistenceCache;
  Node headNode=getNode(entity,objectGraph,initialNodeState);
  objectGraph.setHeadNode(headNode);
  return objectGraph;
}

Fixed version (ground truth):
public ObjectGraph getObjectGraph(Object entity,NodeState initialNodeState,PersistenceCache persistenceCache){
  ObjectGraph objectGraph=new ObjectGraph();
  this.persistenceCache=persistenceCache;
  Node headNode=getNode(entity,objectGraph,initialNodeState);
  if (headNode != null) {
    objectGraph.setHeadNode(headNode);
  }
  return objectGraph;
}
Program: 176926
Project: 176926
Buggy source:
/** 
 * Returns mapped relational name, in case of bi directional mapping, it will return back pKey name of associated entity.
 * @param relation holding relation.
 * @return   mapped/join column name.
 */
public static String getMappedName(EntityMetadata parentMetadata,Relation relation){
  String joinColumn=relation.getJoinColumnName();
  if (joinColumn == null) {
    Class clazz=relation.getTargetEntity();
    EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(clazz);
    joinColumn=relation.getType().equals(ForeignKey.ONE_TO_MANY) ? parentMetadata.getIdColumn().getName() : metadata.getIdColumn().getName();
  }
  return joinColumn;
}

Fixed version (ground truth):
/** 
 * Returns mapped relational name, in case of bi directional mapping, it will return back pKey name of associated entity.
 * @param relation holding relation.
 * @return   mapped/join column name.
 */
public static String getMappedName(EntityMetadata parentMetadata,Relation relation){
  if (relation != null) {
    String joinColumn=relation.getJoinColumnName();
    if (joinColumn == null) {
      Class clazz=relation.getTargetEntity();
      EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(clazz);
      joinColumn=relation.getType().equals(ForeignKey.ONE_TO_MANY) ? parentMetadata.getIdColumn().getName() : metadata.getIdColumn().getName();
    }
    return joinColumn;
  }
  return null;
}
Program: 176927
Project: 176927
Buggy source:
/** 
 * Method to add specific relation name for given relational field.
 * @param rField relation object.
 */
private void addRelationName(Relation rField){
  String relationName=getJoinColumnName(rField.getProperty());
  if (rField.getProperty().isAnnotationPresent(PrimaryKeyJoinColumn.class)) {
    relationName=this.getIdColumn().getName();
  }
  addToRelationNameCollection(relationName);
}

Fixed version (ground truth):
/** 
 * Method to add specific relation name for given relational field.
 * @param rField relation object.
 */
private void addRelationName(Relation rField){
  if (!rField.isRelatedViaJoinTable()) {
    String relationName=getJoinColumnName(rField.getProperty());
    if (rField.getProperty().isAnnotationPresent(PrimaryKeyJoinColumn.class)) {
      relationName=this.getIdColumn().getName();
    }
    addToRelationNameCollection(relationName);
  }
}
Program: 176931
Project: 176931
Buggy source:
@Override public List<?> getResultList(){
  log.info("String_Node_Str" + query);
  List results=null;
  EntityMetadata m=getEntityMetadata();
  Client client=persistenceDelegeator.getClient(m);
  if (m.getRelationNames() == null || (m.getRelationNames().isEmpty() && !m.isRelationViaJoinTable())) {
    results=populateEntities(m,client);
  }
 else {
    results=recursivelyPopulateEntities(m,client);
  }
  if (kunderaQuery.isDeleteUpdate()) {
    onDeleteOrUpdate(results);
  }
  return results != null && !results.isEmpty() ? results : null;
}

Fixed version (ground truth):
@Override public List<?> getResultList(){
  log.info("String_Node_Str" + query);
  List results=null;
  EntityMetadata m=getEntityMetadata();
  Client client=persistenceDelegeator.getClient(m);
  if (!m.isRelationViaJoinTable() && (m.getRelationNames() == null || (m.getRelationNames().isEmpty()))) {
    results=populateEntities(m,client);
  }
 else {
    results=recursivelyPopulateEntities(m,client);
  }
  if (kunderaQuery.isDeleteUpdate()) {
    onDeleteOrUpdate(results);
  }
  return results != null && !results.isEmpty() ? results : null;
}
Program: 176932
Project: 176932
Buggy source:
@Override public <E>List<E> getColumnsById(String joinTableName,String joinColumnName,String inverseJoinColumnName,String parentId){
  StringBuffer sqlQuery=new StringBuffer();
  sqlQuery.append("String_Node_Str").append(inverseJoinColumnName).append("String_Node_Str").append(joinTableName).append("String_Node_Str").append(joinColumnName).append("String_Node_Str").append(parentId).append("String_Node_Str");
  Session s=sf.openSession();
  Transaction tx=s.beginTransaction();
  SQLQuery query=s.createSQLQuery(sqlQuery.toString());
  List<E> foreignKeys=new ArrayList<E>();
  foreignKeys=query.list();
  s.close();
  return foreignKeys;
}

Fixed version (ground truth):
@Override public <E>List<E> getColumnsById(String joinTableName,String joinColumnName,String inverseJoinColumnName,String parentId){
  StringBuffer sqlQuery=new StringBuffer();
  sqlQuery.append("String_Node_Str").append(inverseJoinColumnName).append("String_Node_Str").append(joinTableName).append("String_Node_Str").append(joinColumnName).append("String_Node_Str").append(parentId).append("String_Node_Str");
  Session s=sf.openSession();
  Transaction tx=s.beginTransaction();
  SQLQuery query=s.createSQLQuery(sqlQuery.toString());
  List<E> foreignKeys=new ArrayList<E>();
  foreignKeys=query.list();
  return foreignKeys;
}
Program: 176933
Project: 176933
Buggy source:
/** 
 * Insert record in join table.
 * @param joinTableName the join table name
 * @param joinColumnName the join column name
 * @param inverseJoinColumnName the inverse join column name
 * @param relMetadata the rel metadata
 * @param parentId the parent id
 * @param child the child
 */
private void insertRecordInJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,Object parentId,Set<Object> childrenIds){
  Session s=getStatefulSession();
  Transaction tx=s.beginTransaction();
  for (  Object childId : childrenIds) {
    StringBuffer query=new StringBuffer();
    query.append("String_Node_Str").append(joinTableName).append("String_Node_Str").append(joinColumnName).append("String_Node_Str").append(inverseJoinColumnName).append("String_Node_Str").append("String_Node_Str").append(parentId).append("String_Node_Str").append(childId).append("String_Node_Str");
    s.createSQLQuery(query.toString()).executeUpdate();
  }
  tx.commit();
}

Fixed version (ground truth):
/** 
 * Insert record in join table.
 * @param joinTableName the join table name
 * @param joinColumnName the join column name
 * @param inverseJoinColumnName the inverse join column name
 * @param relMetadata the rel metadata
 * @param parentId the parent id
 * @param child the child
 */
private void insertRecordInJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,Object parentId,Set<Object> childrenIds){
  s=getStatelessSession();
  Transaction tx=s.beginTransaction();
  for (  Object childId : childrenIds) {
    StringBuffer query=new StringBuffer();
    Object[] existingRowIds=findIdsByColumn(joinTableName,joinColumnName,inverseJoinColumnName,(String)childId,null);
    boolean joinTableRecordsExists=false;
    if (existingRowIds != null && existingRowIds.length > 0) {
      for (      Object o : existingRowIds) {
        if (o.toString().equals(parentId.toString())) {
          joinTableRecordsExists=true;
          break;
        }
      }
    }
    if (!joinTableRecordsExists) {
      query.append("String_Node_Str").append(joinTableName).append("String_Node_Str").append(joinColumnName).append("String_Node_Str").append(inverseJoinColumnName).append("String_Node_Str").append("String_Node_Str").append(parentId).append("String_Node_Str").append(childId).append("String_Node_Str");
      s.createSQLQuery(query.toString()).executeUpdate();
    }
  }
  tx.commit();
}
Program: 176934
Project: 176934
Buggy source:
private StatelessSession getStatelessSession(){
  return sf.openStatelessSession();
}

Fixed version (ground truth):
/** 
 * Gets the session instance.
 * @return the session instance
 */
private StatelessSession getStatelessSession(){
  return s != null ? s : sf.openStatelessSession();
}
Program: 176935
Project: 176935
Buggy source:
public List<Object> findByRelation(String colName,String colValue,Class entityClazz){
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClazz);
  String tableName=m.getTableName();
  String aliasName="String_Node_Str" + tableName;
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(tableName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colValue);
  queryBuilder.append("String_Node_Str");
  Session s=getStatefulSession();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(queryBuilder.toString()).addEntity(m.getEntityClazz());
  return q.list();
}

Fixed version (ground truth):
public List<Object> findByRelation(String colName,String colValue,Class entityClazz){
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClazz);
  String tableName=m.getTableName();
  String aliasName="String_Node_Str" + tableName;
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(tableName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colValue);
  queryBuilder.append("String_Node_Str");
  s=getStatelessSession();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(queryBuilder.toString()).addEntity(m.getEntityClazz());
  return q.list();
}
Program: 176936
Project: 176936
Buggy source:
@Override public Object[] findIdsByColumn(String tableName,String pKeyName,String columnName,Object columnValue,Class entityClazz){
  String childIdStr=(String)columnValue;
  StringBuffer sqlQuery=new StringBuffer();
  sqlQuery.append("String_Node_Str").append(pKeyName).append("String_Node_Str").append(tableName).append("String_Node_Str").append(columnName).append("String_Node_Str").append(childIdStr).append("String_Node_Str");
  Session s=sf.openSession();
  Transaction tx=s.beginTransaction();
  SQLQuery query=s.createSQLQuery(sqlQuery.toString());
  List<Object> primaryKeys=new ArrayList<Object>();
  primaryKeys=query.list();
  s.close();
  if (primaryKeys != null && !primaryKeys.isEmpty()) {
    return primaryKeys.toArray(new Object[0]);
  }
  return null;
}

Fixed version (ground truth):
@Override public Object[] findIdsByColumn(String tableName,String pKeyName,String columnName,Object columnValue,Class entityClazz){
  String childIdStr=(String)columnValue;
  StringBuffer sqlQuery=new StringBuffer();
  sqlQuery.append("String_Node_Str").append(pKeyName).append("String_Node_Str").append(tableName).append("String_Node_Str").append(columnName).append("String_Node_Str").append(childIdStr).append("String_Node_Str");
  Session s=sf.openSession();
  Transaction tx=s.beginTransaction();
  SQLQuery query=s.createSQLQuery(sqlQuery.toString());
  List<Object> primaryKeys=new ArrayList<Object>();
  primaryKeys=query.list();
  if (primaryKeys != null && !primaryKeys.isEmpty()) {
    return primaryKeys.toArray(new Object[0]);
  }
  return null;
}
Program: 176937
Project: 176937
Buggy source:
public void deleteByColumn(String tableName,String columnName,Object columnValue){
  StringBuffer query=new StringBuffer();
  query.append("String_Node_Str").append(tableName).append("String_Node_Str").append(columnName).append("String_Node_Str").append("String_Node_Str").append(columnValue).append("String_Node_Str");
  Session s=getStatefulSession();
  Transaction tx=s.beginTransaction();
  s.createSQLQuery(query.toString()).executeUpdate();
  tx.commit();
}

Fixed version (ground truth):
public void deleteByColumn(String tableName,String columnName,Object columnValue){
  StringBuffer query=new StringBuffer();
  query.append("String_Node_Str").append(tableName).append("String_Node_Str").append(columnName).append("String_Node_Str").append("String_Node_Str").append(columnValue).append("String_Node_Str");
  s=getStatelessSession();
  Transaction tx=s.beginTransaction();
  s.createSQLQuery(query.toString()).executeUpdate();
  tx.commit();
}
Program: 176938
Project: 176938
Buggy source:
/** 
 * Find.
 * @param nativeQuery the native fquery
 * @param relations the relations
 * @param m the m
 * @return the list
 */
public List find(String nativeQuery,List<String> relations,EntityMetadata m){
  List<Object[]> result=new ArrayList<Object[]>();
  s=sf.openStatelessSession();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(nativeQuery).addEntity(m.getEntityClazz());
  for (  String r : relations) {
    if (!m.getIdColumn().getName().equalsIgnoreCase(r)) {
      q.addScalar(r);
    }
  }
  return q.list();
}

Fixed version (ground truth):
/** 
 * Find.
 * @param nativeQuery the native fquery
 * @param relations the relations
 * @param m the m
 * @return the list
 */
public List find(String nativeQuery,List<String> relations,EntityMetadata m){
  List<Object[]> result=new ArrayList<Object[]>();
  s=getStatelessSession();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(nativeQuery).addEntity(m.getEntityClazz());
  if (relations != null) {
    for (    String r : relations) {
      String name=MetadataUtils.getMappedName(m,m.getRelation(r));
      if (!m.getIdColumn().getName().equalsIgnoreCase(name != null ? name : r)) {
        q.addScalar(name != null ? name : r);
      }
    }
  }
  return q.list();
}
Program: 176941
Project: 176941
Buggy source:
/** 
 * @param node
 * @param entityMetadata
 */
protected void indexNode(Node node,EntityMetadata entityMetadata,IndexManager indexManager){
  Map<NodeLink,Node> parents=node.getParents();
  if (parents != null) {
    for (    NodeLink parentNodeLink : parents.keySet()) {
      indexManager.update(entityMetadata,node.getData(),(String)parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE),parents.get(parentNodeLink).getDataClass());
    }
  }
 else {
    indexManager.update(entityMetadata,node.getData(),null,null);
  }
}

Fixed version (ground truth):
/** 
 * @param node
 * @param entityMetadata
 */
protected void indexNode(Node node,EntityMetadata entityMetadata,IndexManager indexManager){
  Map<NodeLink,Node> parents=node.getParents();
  if (parents != null) {
    for (    NodeLink parentNodeLink : parents.keySet()) {
      indexManager.update(entityMetadata,node.getData(),(String)parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE),parents.get(parentNodeLink).getDataClass());
    }
  }
 else   if (node.getChildren() != null) {
    Map<NodeLink,Node> children=node.getChildren();
    for (    NodeLink childNodeLink : children.keySet()) {
      if (childNodeLink.getMultiplicity().equals(ForeignKey.MANY_TO_ONE)) {
        indexManager.update(entityMetadata,node.getData(),(String)childNodeLink.getLinkProperty(LinkProperty.LINK_VALUE),children.get(childNodeLink).getDataClass());
      }
 else {
        indexManager.update(entityMetadata,node.getData(),null,null);
      }
    }
  }
 else {
    indexManager.update(entityMetadata,node.getData(),null,null);
  }
}
Program: 176942
Project: 176942
Buggy source:
@Override public int hashCode(){
  return getSourceNodeId().hashCode() * getTargetNodeId().hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  int n=getSourceNodeId().hashCode() * getTargetNodeId().hashCode();
  return n;
}