nus-yam/ex-repair huggingface dataset:
Program: 176693
Project: 176693
Buggy source:
/** 
 * Try operation.
 * @param ALL_PUs_UNDER_TEST
 */
protected void tryOperation(String[] ALL_PUs_UNDER_TEST){
  try {
    Metamodel metaModel=null;
    for (int i=0; i < ALL_PUs_UNDER_TEST.length; i++) {
      metaModel=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(ALL_PUs_UNDER_TEST[i]);
      for (int i1=0; i1 < ALL_PUs_UNDER_TEST.length; i1++) {
        if (i != i1) {
          Map<Class<?>,EntityType<?>> original=getManagedTypes((MetamodelImpl)metaModel);
          Metamodel m=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(ALL_PUs_UNDER_TEST[i1]);
          Map<Class<?>,EntityType<?>> copy=getManagedTypes((MetamodelImpl)m);
          if (original != null && copy != null) {
            original.putAll(copy);
          }
        }
      }
    }
    for (    Map<Class,String> c : combinations) {
      Set<String> allPus=new HashSet<String>(c.values());
      if (allPus.size() == 1) {
        continue;
      }
 else {
        String puForActor=c.get(Actor.class);
        String puForMovie=c.get(Movie.class);
        if (puForActor.equals("String_Node_Str") && puForMovie.equals("String_Node_Str")) {
          continue;
        }
      }
      switchPersistenceUnits(c);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    log.error(e);
    Assert.fail("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Try operation.
 * @param ALL_PUs_UNDER_TEST
 */
protected void tryOperation(String[] ALL_PUs_UNDER_TEST){
  try {
    Metamodel metaModel=null;
    for (int i=0; i < ALL_PUs_UNDER_TEST.length; i++) {
      metaModel=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(ALL_PUs_UNDER_TEST[i]);
      for (int i1=0; i1 < ALL_PUs_UNDER_TEST.length; i1++) {
        if (i != i1) {
          Map<Class<?>,EntityType<?>> original=getManagedTypes((MetamodelImpl)metaModel);
          Metamodel m=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(ALL_PUs_UNDER_TEST[i1]);
          Map<Class<?>,EntityType<?>> copy=getManagedTypes((MetamodelImpl)m);
          if (original != null && copy != null) {
            original.putAll(copy);
          }
        }
      }
    }
    for (    Map<Class,String> c : combinations) {
      Set<String> allPus=new HashSet<String>(c.values());
      if (allPus.size() == 1) {
        continue;
      }
 else {
        String puForActor=c.get(Actor.class);
        String puForMovie=c.get(Movie.class);
        if (puForActor.equals("String_Node_Str") && puForMovie.equals("String_Node_Str")) {
          continue;
        }
      }
      switchPersistenceUnits(c);
      insert();
      find();
      tearDownInternal(ALL_PUs_UNDER_TEST);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    log.error(e);
    Assert.fail("String_Node_Str" + e.getMessage());
  }
}
Program: 176694
Project: 176694
Buggy source:
protected void onpersistOverCompositeKey(EntityMetadata entityMetadata,Object entity,Cassandra.Client cassandra_client) throws InvalidRequestException, TException, UnavailableException, TimedOutException, SchemaDisagreementException, UnsupportedEncodingException {
  cassandra_client.set_cql_version(getCqlVersion());
  CQLTranslator translator=new CQLTranslator();
  String insert_Query=translator.INSERT_QUERY;
  insert_Query=StringUtils.replace(insert_Query,CQLTranslator.COLUMN_FAMILY,translator.ensureCase(new StringBuilder(),entityMetadata.getTableName()).toString());
  HashMap<TranslationType,String> translation=translator.prepareColumnOrColumnValues(entity,entityMetadata,TranslationType.ALL);
  insert_Query=StringUtils.replace(insert_Query,CQLTranslator.COLUMN_VALUES,translation.get(TranslationType.VALUE));
  insert_Query=StringUtils.replace(insert_Query,CQLTranslator.COLUMNS,translation.get(TranslationType.COLUMN));
  cassandra_client.execute_cql3_query(ByteBuffer.wrap(insert_Query.getBytes(Constants.CHARSET_UTF8)),Compression.NONE,consistencyLevel);
}

Fixed version (ground truth):
protected void onpersistOverCompositeKey(EntityMetadata entityMetadata,Object entity,Cassandra.Client cassandra_client,List<RelationHolder> rlHolders) throws InvalidRequestException, TException, UnavailableException, TimedOutException, SchemaDisagreementException, UnsupportedEncodingException {
  cassandra_client.set_cql_version(getCqlVersion());
  CQLTranslator translator=new CQLTranslator();
  String insert_Query=translator.INSERT_QUERY;
  insert_Query=StringUtils.replace(insert_Query,CQLTranslator.COLUMN_FAMILY,translator.ensureCase(new StringBuilder(),entityMetadata.getTableName()).toString());
  HashMap<TranslationType,String> translation=translator.prepareColumnOrColumnValues(entity,entityMetadata,TranslationType.ALL);
  String columnNames=translation.get(TranslationType.COLUMN);
  String columnValues=translation.get(TranslationType.VALUE);
  StringBuilder columnNameBuilder=new StringBuilder(columnNames);
  StringBuilder columnValueBuilder=new StringBuilder(columnValues);
  for (  RelationHolder rl : rlHolders) {
    columnNameBuilder.append("String_Node_Str");
    columnValueBuilder.append("String_Node_Str");
    translator.appendColumnName(columnNameBuilder,rl.getRelationName());
    translator.appendValue(columnValueBuilder,rl.getRelationValue().getClass(),rl.getRelationValue(),true);
  }
  translation.put(TranslationType.COLUMN,columnNameBuilder.toString());
  translation.put(TranslationType.VALUE,columnValueBuilder.toString());
  insert_Query=StringUtils.replace(insert_Query,CQLTranslator.COLUMN_VALUES,translation.get(TranslationType.VALUE));
  insert_Query=StringUtils.replace(insert_Query,CQLTranslator.COLUMNS,translation.get(TranslationType.COLUMN));
  cassandra_client.execute_cql3_query(ByteBuffer.wrap(insert_Query.getBytes(Constants.CHARSET_UTF8)),Compression.NONE,consistencyLevel);
}
Program: 176697
Project: 176697
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<Object> onQueryOverCompositeColumns(EntityMetadata m,Client client,MetamodelImpl metaModel){
  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(),null);
  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;
  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: 176698
Project: 176698
Buggy source:
@Override protected List<Object> recursivelyPopulateEntities(EntityMetadata m,Client client){
  List<EnhanceEntity> ls=null;
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  if (appMetadata.isNative(getJPAQuery())) {
    ls=(List<EnhanceEntity>)((CassandraClientBase)client).executeQuery(appMetadata.getQuery(getJPAQuery()),m.getEntityClazz(),null);
  }
 else {
    boolean useInvertedIndex=CassandraIndexHelper.isInvertedIndexingApplicable(m);
    Map<Boolean,List<IndexClause>> ixClause=MetadataUtils.useSecondryIndex(m.getPersistenceUnit()) ? prepareIndexClause(m,useInvertedIndex) : null;
    if (useInvertedIndex && !getKunderaQuery().getFilterClauseQueue().isEmpty()) {
      ls=((CassandraEntityReader)getReader()).readFromIndexTable(m,client,ixClause);
    }
 else {
      ((CassandraEntityReader)getReader()).setConditions(ixClause);
      ls=reader.populateRelation(m,client);
    }
  }
  return setRelationEntities(ls,client,m);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override protected List<Object> recursivelyPopulateEntities(EntityMetadata m,Client client){
  List<EnhanceEntity> ls=null;
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  if (appMetadata.isNative(getJPAQuery())) {
    ls=(List<EnhanceEntity>)((CassandraClientBase)client).executeQuery(appMetadata.getQuery(getJPAQuery()),m.getEntityClazz(),null);
  }
 else   if (!appMetadata.isNative(getJPAQuery()) && metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType())) {
    ls=onQueryOverCompositeColumns(m,client,metaModel,m.getRelationNames());
  }
 else {
    boolean useInvertedIndex=CassandraIndexHelper.isInvertedIndexingApplicable(m);
    Map<Boolean,List<IndexClause>> ixClause=MetadataUtils.useSecondryIndex(m.getPersistenceUnit()) ? prepareIndexClause(m,useInvertedIndex) : null;
    if (useInvertedIndex && !getKunderaQuery().getFilterClauseQueue().isEmpty()) {
      ls=((CassandraEntityReader)getReader()).readFromIndexTable(m,client,ixClause);
    }
 else {
      ((CassandraEntityReader)getReader()).setConditions(ixClause);
      ls=reader.populateRelation(m,client);
    }
  }
  return setRelationEntities(ls,client,m);
}
Program: 176699
Project: 176699
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.
 */
private 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)|| 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;
}
Program: 176701
Project: 176701
Buggy source:
@Override public final EntityTransaction getTransaction(){
  if (this.transactionType == PersistenceUnitTransactionType.JTA) {
    throw new IllegalStateException("String_Node_Str");
  }
  return this.entityTransaction;
}

Fixed version (ground truth):
@Override public final EntityTransaction getTransaction(){
  if (this.transactionType == PersistenceUnitTransactionType.JTA) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (this.entityTransaction == null) {
    this.entityTransaction=new KunderaEntityTransaction(this);
  }
  return this.entityTransaction;
}
Program: 176702
Project: 176702
Buggy source:
@Override public void doRollback(){
  checkClosed();
  this.entityTransaction.rollback();
}

Fixed version (ground truth):
@Override public void doRollback(){
  checkClosed();
  if (this.entityTransaction != null) {
    this.entityTransaction.rollback();
  }
 else {
    this.persistenceDelegator.rollback();
  }
}
Program: 176704
Project: 176704
Buggy source:
@Test public void testOps(){
  String humanId="String_Node_Str";
  Human human=new Human(humanId);
  human.setHumanAlive(true);
  HumansPrivatePhoto photo=new HumansPrivatePhoto(humanId);
  photo.setPhotoName("String_Node_Str");
  human.setHumansPrivatePhoto(photo);
  photo.setHuman(human);
  em.persist(human);
  em.clear();
  Human result=em.find(Human.class,humanId);
  System.out.println(result);
}

Fixed version (ground truth):
@Test public void testOps(){
  String humanId="String_Node_Str";
  Human human=new Human(humanId);
  human.setHumanAlive(true);
  HumansPrivatePhoto photo=new HumansPrivatePhoto(humanId);
  photo.setPhotoName("String_Node_Str");
  human.setHumansPrivatePhoto(photo);
  photo.setHuman(human);
  em.persist(human);
  em.clear();
  Human result=em.find(Human.class,humanId);
  Assert.assertNotNull(result);
  Assert.assertEquals(humanId,result.getHumanId());
  Assert.assertEquals("String_Node_Str",result.getHumansPrivatePhoto().getPhotoName());
  Assert.assertTrue(result.getHumanAlive());
}
Program: 176705
Project: 176705
Buggy source:
@After public void tearDown(){
  em.close();
  emf.close();
  if (cli != null && cli.isStarted()) {
    cli.dropTable("String_Node_Str");
    cli.dropTable("String_Node_Str");
    cli.stopCluster("String_Node_Str");
  }
}

Fixed version (ground truth):
@After public void tearDown(){
  em.close();
  emf.close();
  if (cli != null && cli.isStarted()) {
    cli.dropTable("String_Node_Str");
    cli.dropTable("String_Node_Str");
  }
}
Program: 176706
Project: 176706
Buggy source:
/** 
 * @param columns
 * @param m
 * @return
 */
private String[] getTranslatedColumns(EntityMetadata m,String[] columns){
  if (columns != null) {
    String[] translatedColumns=new String[columns.length - 1];
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
    EntityType entity=metaModel.entity(m.getEntityClazz());
    int count=0;
    for (int i=1; i < columns.length; i++) {
      if (columns[i] != null) {
        Attribute col=entity.getAttribute(columns[i]);
        if (col == null) {
          throw new QueryHandlerException("String_Node_Str" + columns[i]);
        }
        translatedColumns[count++]=((AbstractAttribute)col).getJPAColumnName();
      }
    }
    return translatedColumns;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param columns
 * @param m
 * @return
 */
private List<String> getTranslatedColumns(EntityMetadata m,String[] columns){
  List<String> translatedColumns=new ArrayList<String>();
  if (columns != null) {
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
    EntityType entity=metaModel.entity(m.getEntityClazz());
    int count=0;
    for (int i=1; i < columns.length; i++) {
      if (columns[i] != null) {
        String fieldName=null;
        String embeddedFieldName=null;
        StringTokenizer stringTokenizer=new StringTokenizer(columns[i],"String_Node_Str");
        if (stringTokenizer.countTokens() > 1) {
          fieldName=stringTokenizer.nextToken();
          embeddedFieldName=stringTokenizer.nextToken();
          Attribute col=entity.getAttribute(fieldName);
          EmbeddableType embeddableType=metaModel.embeddable(col.getJavaType());
          Attribute attribute=embeddableType.getAttribute(embeddedFieldName);
          translatedColumns.add(((AbstractAttribute)attribute).getJPAColumnName());
        }
 else {
          fieldName=columns[i];
          Attribute col=entity.getAttribute(fieldName);
          onEmbeddable(translatedColumns,metaModel,col,metaModel.isEmbeddable(((AbstractAttribute)col).getBindableJavaType()));
        }
      }
    }
  }
  return translatedColumns;
}
Program: 176707
Project: 176707
Buggy source:
private byte[] getBytes(String jpaFieldName,EntityMetadata m,Object value){
  Attribute idCol=m.getIdAttribute();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  EntityType entity=metaModel.entity(m.getEntityClazz());
  Field f=null;
  boolean isId=false;
  if (idCol.getName().equals(jpaFieldName)) {
    f=(Field)idCol.getJavaMember();
    isId=true;
  }
 else {
    String fieldName=m.getFieldName(jpaFieldName);
    Attribute col=entity.getAttribute(fieldName);
    if (col == null) {
      throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
    }
    f=(Field)col.getJavaMember();
  }
  if (f != null && f.getType() != null) {
    return HBaseUtils.getBytes(value,f.getType());
  }
 else {
    log.error("String_Node_Str" + jpaFieldName);
    throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
  }
}

Fixed version (ground truth):
private byte[] getBytes(String jpaFieldName,EntityMetadata m,Object value){
  Attribute idCol=m.getIdAttribute();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  EntityType entity=metaModel.entity(m.getEntityClazz());
  Class fieldClazz=null;
  boolean isId=false;
  if (idCol.getName().equals(jpaFieldName)) {
    Field f=(Field)idCol.getJavaMember();
    fieldClazz=f.getType();
    isId=true;
  }
 else {
    StringTokenizer tokenizer=new StringTokenizer(jpaFieldName,"String_Node_Str");
    String embeddedFieldName=null;
    if (tokenizer.countTokens() > 1) {
      embeddedFieldName=tokenizer.nextToken();
      String fieldName=tokenizer.nextToken();
      Attribute embeddableAttribute=entity.getAttribute(embeddedFieldName);
      EmbeddableType embeddableType=metaModel.embeddable(embeddableAttribute.getJavaType());
      Attribute embeddedAttribute=embeddableType.getAttribute(fieldName);
      jpaFieldName=((AbstractAttribute)embeddedAttribute).getJPAColumnName();
      fieldClazz=((AbstractAttribute)embeddedAttribute).getBindableJavaType();
    }
 else {
      String fieldName=m.getFieldName(jpaFieldName);
      Attribute col=entity.getAttribute(fieldName);
      if (col == null) {
        throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
      }
      fieldClazz=((AbstractAttribute)col).getBindableJavaType();
    }
  }
  if (fieldClazz != null) {
    return HBaseUtils.getBytes(value,fieldClazz);
  }
 else {
    log.error("String_Node_Str" + jpaFieldName);
    throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
  }
}
Program: 176709
Project: 176709
Buggy source:
/** 
 * get Table metadata method returns the HTableDescriptor of table for given tableInfo
 * @return HHTableDescriptor object for tableInfo
 */
private HTableDescriptor getTableMetaData(TableInfo tableInfo){
  HTableDescriptor tableDescriptor=new HTableDescriptor(tableInfo.getTableName());
  Properties tableProperties=null;
  schemas=HBasePropertyReader.hsmd.getDataStore() != null ? HBasePropertyReader.hsmd.getDataStore().getSchemas() : null;
  if (schemas != null && !schemas.isEmpty()) {
    for (    Schema s : schemas) {
      if (s.getName() != null && s.getName().equalsIgnoreCase(tableInfo.getTableName())) {
        tableProperties=s.getSchemaProperties();
        tables=s.getTables();
      }
    }
  }
  if (tableInfo.getColumnMetadatas() != null) {
    HColumnDescriptor hColumnDescriptor=new HColumnDescriptor(tableInfo.getTableName());
    setColumnFamilyProperties(hColumnDescriptor,tableInfo.getTableName());
    tableDescriptor.addFamily(hColumnDescriptor);
  }
  if (tableInfo.getEmbeddedColumnMetadatas() != null) {
  }
  if (tableProperties != null) {
    for (    Object o : tableProperties.keySet()) {
      tableDescriptor.setValue(Bytes.toBytes(o.toString()),Bytes.toBytes(tableProperties.get(o).toString()));
    }
  }
  return tableDescriptor;
}

Fixed version (ground truth):
/** 
 * get Table metadata method returns the HTableDescriptor of table for given tableInfo
 * @return HHTableDescriptor object for tableInfo
 */
private HTableDescriptor getTableMetaData(TableInfo tableInfo){
  HTableDescriptor tableDescriptor=new HTableDescriptor(tableInfo.getTableName());
  Properties tableProperties=null;
  schemas=HBasePropertyReader.hsmd.getDataStore() != null ? HBasePropertyReader.hsmd.getDataStore().getSchemas() : null;
  if (schemas != null && !schemas.isEmpty()) {
    for (    Schema s : schemas) {
      if (s.getName() != null && s.getName().equalsIgnoreCase(tableInfo.getTableName())) {
        tableProperties=s.getSchemaProperties();
        tables=s.getTables();
      }
    }
  }
  if (tableInfo.getColumnMetadatas() != null) {
    HColumnDescriptor hColumnDescriptor=new HColumnDescriptor(tableInfo.getTableName());
    setColumnFamilyProperties(hColumnDescriptor,tableInfo.getTableName());
    tableDescriptor.addFamily(hColumnDescriptor);
  }
  if (tableProperties != null) {
    for (    Object o : tableProperties.keySet()) {
      tableDescriptor.setValue(Bytes.toBytes(o.toString()),Bytes.toBytes(tableProperties.get(o).toString()));
    }
  }
  return tableDescriptor;
}
Program: 176711
Project: 176711
Buggy source:
/** 
 * validate method validate schema and table for the list of tableInfos.
 * @param tableInfos list of TableInfos.
 */
protected void validate(List<TableInfo> tableInfos){
  for (  TableInfo tableInfo : tableInfos) {
    HTableDescriptor hTableDescriptor;
    try {
      hTableDescriptor=admin.getTableDescriptor(tableInfo.getTableName().getBytes());
      if (tableInfo.getColumnMetadatas() != null) {
        boolean isColumnFound=false;
        for (        HColumnDescriptor columnDescriptor : hTableDescriptor.getColumnFamilies()) {
          if (columnDescriptor.getNameAsString().equalsIgnoreCase(tableInfo.getTableName())) {
            isColumnFound=true;
            break;
          }
        }
        if (!isColumnFound) {
          throw new SchemaGenerationException("String_Node_Str" + tableInfo.getTableName() + "String_Node_Str"+ tableInfo.getTableName()+ "String_Node_Str","String_Node_Str",tableInfo.getTableName(),tableInfo.getTableName());
        }
      }
      if (tableInfo.getEmbeddedColumnMetadatas() != null) {
      }
    }
 catch (    TableNotFoundException tnfex) {
      throw new SchemaGenerationException("String_Node_Str" + tableInfo.getTableName() + "String_Node_Str",tnfex,"String_Node_Str");
    }
catch (    IOException e) {
      logger.error("String_Node_Str" + e.getMessage());
      throw new SchemaGenerationException(e,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * validate method validate schema and table for the list of tableInfos.
 * @param tableInfos list of TableInfos.
 */
protected void validate(List<TableInfo> tableInfos){
  for (  TableInfo tableInfo : tableInfos) {
    HTableDescriptor hTableDescriptor;
    try {
      hTableDescriptor=admin.getTableDescriptor(tableInfo.getTableName().getBytes());
      if (tableInfo.getColumnMetadatas() != null) {
        boolean isColumnFound=false;
        for (        HColumnDescriptor columnDescriptor : hTableDescriptor.getColumnFamilies()) {
          if (columnDescriptor.getNameAsString().equalsIgnoreCase(tableInfo.getTableName())) {
            isColumnFound=true;
            break;
          }
        }
        if (!isColumnFound) {
          throw new SchemaGenerationException("String_Node_Str" + tableInfo.getTableName() + "String_Node_Str"+ tableInfo.getTableName()+ "String_Node_Str","String_Node_Str",tableInfo.getTableName(),tableInfo.getTableName());
        }
      }
    }
 catch (    TableNotFoundException tnfex) {
      throw new SchemaGenerationException("String_Node_Str" + tableInfo.getTableName() + "String_Node_Str",tnfex,"String_Node_Str");
    }
catch (    IOException e) {
      logger.error("String_Node_Str" + e.getMessage());
      throw new SchemaGenerationException(e,"String_Node_Str");
    }
  }
}
Program: 176712
Project: 176712
Buggy source:
/** 
 * @param columns
 * @param m
 * @return
 */
private List<String> getTranslatedColumns(EntityMetadata m,String[] columns){
  List<String> translatedColumns=new ArrayList<String>();
  if (columns != null) {
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
    EntityType entity=metaModel.entity(m.getEntityClazz());
    int count=0;
    for (int i=1; i < columns.length; i++) {
      if (columns[i] != null) {
        String fieldName=null;
        String embeddedFieldName=null;
        StringTokenizer stringTokenizer=new StringTokenizer(columns[i],"String_Node_Str");
        if (stringTokenizer.countTokens() > 1) {
          fieldName=stringTokenizer.nextToken();
          embeddedFieldName=stringTokenizer.nextToken();
          Attribute col=entity.getAttribute(fieldName);
          EmbeddableType embeddableType=metaModel.embeddable(col.getJavaType());
          Attribute attribute=embeddableType.getAttribute(embeddedFieldName);
          translatedColumns.add(((AbstractAttribute)attribute).getJPAColumnName());
        }
 else {
          fieldName=columns[i];
          Attribute col=entity.getAttribute(fieldName);
          onEmbeddable(translatedColumns,metaModel,col,metaModel.isEmbeddable(((AbstractAttribute)col).getBindableJavaType()));
        }
      }
    }
  }
  return translatedColumns;
}

Fixed version (ground truth):
/** 
 * @param columns
 * @param m
 * @return
 */
private List<String> getTranslatedColumns(EntityMetadata m,String[] columns,final int startWith){
  List<String> translatedColumns=new ArrayList<String>();
  if (columns != null) {
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
    EntityType entity=metaModel.entity(m.getEntityClazz());
    int count=0;
    for (int i=startWith; i < columns.length; i++) {
      if (columns[i] != null) {
        String fieldName=null;
        String embeddedFieldName=null;
        StringTokenizer stringTokenizer=new StringTokenizer(columns[i],"String_Node_Str");
        if (stringTokenizer.countTokens() > 1) {
          fieldName=stringTokenizer.nextToken();
          embeddedFieldName=stringTokenizer.nextToken();
          Attribute col=entity.getAttribute(fieldName);
          EmbeddableType embeddableType=metaModel.embeddable(col.getJavaType());
          Attribute attribute=embeddableType.getAttribute(embeddedFieldName);
          translatedColumns.add(((AbstractAttribute)attribute).getJPAColumnName());
        }
 else {
          fieldName=columns[i];
          Attribute col=entity.getAttribute(fieldName);
          onEmbeddable(translatedColumns,metaModel,col,metaModel.isEmbeddable(((AbstractAttribute)col).getBindableJavaType()));
        }
      }
    }
  }
  return translatedColumns;
}
Program: 176714
Project: 176714
Buggy source:
/** 
 * On parsing filter clause(e.g. WHERE clause).
 * @param condition condition
 * @param name column name.
 * @param value column value.
 * @param isIdColumn if it is an id column.
 * @param m entity metadata.
 */
private void onParseFilter(String condition,String name,Object value,boolean isIdColumn,EntityMetadata m){
  CompareOp operator=HBaseUtils.getOperator(condition,isIdColumn);
  byte[] valueInBytes=getBytes(name,m,value);
  if (!isIdColumn) {
    Filter f=new SingleColumnValueFilter(Bytes.toBytes(m.getTableName()),Bytes.toBytes(name),operator,valueInBytes);
    addToFilter(f);
  }
 else {
    if (operator.equals(CompareOp.GREATER_OR_EQUAL) || operator.equals(CompareOp.GREATER)) {
      startRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.LESS_OR_EQUAL) || operator.equals(CompareOp.LESS)) {
      endRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.EQUAL)) {
      rowKey=getBytes(m.getIdAttribute().getName(),m,value);
      endRow=null;
      isFindById=true;
    }
  }
  this.isIdColumn=isIdColumn;
}

Fixed version (ground truth):
/** 
 * On parsing filter clause(e.g. WHERE clause).
 * @param condition condition
 * @param name column name.
 * @param value column value.
 * @param isIdColumn if it is an id column.
 * @param m entity metadata.
 */
private void onParseFilter(String condition,String name,Object value,boolean isIdColumn,EntityMetadata m){
  CompareOp operator=HBaseUtils.getOperator(condition,isIdColumn);
  byte[] valueInBytes=getBytes(name,m,value);
  if (!isIdColumn) {
    List<String> columns=null;
    if (new StringTokenizer(name,"String_Node_Str").countTokens() > 1) {
      columns=getTranslatedColumns(m,new String[]{name},0);
    }
    if (columns != null && !columns.isEmpty()) {
      name=columns.get(0);
    }
    Filter f=new SingleColumnValueFilter(Bytes.toBytes(m.getTableName()),Bytes.toBytes(name),operator,valueInBytes);
    addToFilter(f);
  }
 else {
    if (operator.equals(CompareOp.GREATER_OR_EQUAL) || operator.equals(CompareOp.GREATER)) {
      startRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.LESS_OR_EQUAL) || operator.equals(CompareOp.LESS)) {
      endRow=valueInBytes;
    }
 else     if (operator.equals(CompareOp.EQUAL)) {
      rowKey=getBytes(m.getIdAttribute().getName(),m,value);
      endRow=null;
      isFindById=true;
    }
  }
  this.isIdColumn=isIdColumn;
}
Program: 176717
Project: 176717
Buggy source:
@Test public void testSelectAll(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(1,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertEquals("String_Node_Str",result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}

Fixed version (ground truth):
@Test public void testSelectAll(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(4,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertEquals("String_Node_Str",result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}
Program: 176718
Project: 176718
Buggy source:
@Test public void testSelectTwoSpecificColumnOfEmbeddable(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(1,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertEquals("String_Node_Str",result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}

Fixed version (ground truth):
@Test public void testSelectTwoSpecificColumnOfEmbeddable(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  query.setParameter("String_Node_Str",CAPTURE_TIME1);
  query.setParameter("String_Node_Str",CAPTURE_TIME3);
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(3,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertEquals("String_Node_Str",result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}
Program: 176719
Project: 176719
Buggy source:
/** 
 */
private void persist(){
  NetstatData data=new NetstatData();
  NetstatDataId id=new NetstatDataId();
  id.setServer("String_Node_Str");
  data.setRowKey("String_Node_Str");
  id.setCaptureTime(CAPTURE_TIME);
  id.setPortMapTypeCd("String_Node_Str");
  data.setEstablished(1);
  data.setTotal(1);
  data.setId(id);
  em.persist(data);
  em.clear();
}

Fixed version (ground truth):
/** 
 */
private void persist(){
  NetstatData data=new NetstatData();
  NetstatDataId id=new NetstatDataId();
  id.setServer("String_Node_Str");
  data.setRowKey("String_Node_Str");
  id.setCaptureTime(CAPTURE_TIME);
  id.setPortMapTypeCd("String_Node_Str");
  data.setEstablished(1);
  data.setTotal(1);
  data.setId(id);
  em.persist(data);
  NetstatData data1=new NetstatData();
  NetstatDataId id1=new NetstatDataId();
  id1.setServer("String_Node_Str");
  data1.setRowKey("String_Node_Str");
  id1.setCaptureTime(CAPTURE_TIME1);
  id1.setPortMapTypeCd("String_Node_Str");
  data1.setEstablished(2);
  data1.setTotal(2);
  data1.setId(id1);
  em.persist(data1);
  NetstatData data2=new NetstatData();
  NetstatDataId id2=new NetstatDataId();
  id2.setServer("String_Node_Str");
  data2.setRowKey("String_Node_Str");
  id2.setCaptureTime(CAPTURE_TIME2);
  id2.setPortMapTypeCd("String_Node_Str");
  data2.setEstablished(3);
  data2.setTotal(3);
  data2.setId(id2);
  em.persist(data2);
  NetstatData data3=new NetstatData();
  NetstatDataId id3=new NetstatDataId();
  id3.setServer("String_Node_Str");
  data3.setRowKey("String_Node_Str");
  id3.setCaptureTime(CAPTURE_TIME3);
  id3.setPortMapTypeCd("String_Node_Str");
  data3.setEstablished(4);
  data3.setTotal(4);
  data3.setId(id3);
  em.persist(data3);
  em.clear();
}
Program: 176720
Project: 176720
Buggy source:
@Test public void testSelectOnlySpecificColumnOfEmbeddable(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(1,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertNull(result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}

Fixed version (ground truth):
@Test public void testSelectOnlySpecificColumnOfEmbeddable(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(2,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME2,result.get(0).getId().getCaptureTime());
  Assert.assertNull(result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}
Program: 176721
Project: 176721
Buggy source:
@Test public void testSelectEmbeddedColumn(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(1,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertEquals("String_Node_Str",result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}

Fixed version (ground truth):
@Test public void testSelectEmbeddedColumn(){
  persist();
  String query2="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  Query query=em.createQuery(query2);
  query.setParameter("String_Node_Str","String_Node_Str");
  List<NetstatData> result=query.getResultList();
  Assert.assertNotNull(result);
  Assert.assertEquals(2,result.size());
  Assert.assertNotNull(result.get(0));
  Assert.assertNotNull(result.get(0).getId());
  Assert.assertEquals(CAPTURE_TIME,result.get(0).getId().getCaptureTime());
  Assert.assertEquals("String_Node_Str",result.get(0).getId().getServer());
  Assert.assertNull(result.get(0).getId().getPortMapId());
}
Program: 176722
Project: 176722
Buggy source:
@Override protected void setUp() throws Exception {
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  KunderaMetadata.INSTANCE.setApplicationMetadata(null);
  setUpInternal("String_Node_Str");
}
Program: 176723
Project: 176723
Buggy source:
/** 
 * Test on execute.
 */
@Test public void testOnExecute(){
}

Fixed version (ground truth):
/** 
 * Test on execute.
 */
@Test public void testOnExecute(){
  executeTestSuite();
}
Program: 176724
Project: 176724
Buggy source:
@Override protected void tearDown() throws Exception {
}

Fixed version (ground truth):
@Override protected void tearDown() throws Exception {
  tearDownInternal();
}
Program: 176725
Project: 176725
Buggy source:
@Override public void closeEntityManager(){
  if (em != null) {
    em.close();
    em=null;
  }
}

Fixed version (ground truth):
@Override public void closeEntityManager(){
  if (em != null) {
    em.clear();
    em.close();
    em=null;
  }
}
Program: 176728
Project: 176728
Buggy source:
@Test public void testCRUD(){
  tryOperation(ALL_PUs_UNDER_TEST);
}

Fixed version (ground truth):
public void testCRUD(){
  tryOperation(ALL_PUs_UNDER_TEST);
}
Program: 176729
Project: 176729
Buggy source:
public void withTransaction(){
  try {
    prepareData();
    em.getTransaction().begin();
    em.persist(actor1);
    em.persist(actor2);
    em.getTransaction().commit();
    em.clear();
    Actor actor11=em.find(Actor.class,1);
    Actor actor22=em.find(Actor.class,2);
    assertActors(actor11,actor22);
    em.clear();
    actor1.setName("String_Node_Str");
    actor2.setName("String_Node_Str");
    em.getTransaction().begin();
    em.merge(actor1);
    em.merge(actor2);
    em.getTransaction().commit();
    em.clear();
    Actor actor1AfterMerge=em.find(Actor.class,1);
    Actor actor2AfterMerge=em.find(Actor.class,2);
    assertUpdatedActors(actor1AfterMerge,actor2AfterMerge);
    em.clear();
    em.getTransaction().begin();
    em.remove(actor11);
    em.getTransaction().commit();
    em.getTransaction().begin();
    em.remove(actor22);
    em.getTransaction().commit();
    em.clear();
    Actor actor1AfterDeletion=em.find(Actor.class,1);
    Actor actor2AfterDeletion=em.find(Actor.class,2);
    Assert.assertNull(actor1AfterDeletion);
    Assert.assertNull(actor2AfterDeletion);
  }
 catch (  Exception e) {
    Assert.fail(e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void withTransaction(){
  try {
    prepareData();
    em.getTransaction().begin();
    em.persist(actor1);
    em.persist(actor2);
    em.getTransaction().commit();
    Actor actor11=em.find(Actor.class,1);
    Actor actor22=em.find(Actor.class,2);
    assertActors(actor11,actor22);
    em.clear();
    actor1.setName("String_Node_Str");
    actor2.setName("String_Node_Str");
    em.getTransaction().begin();
    em.merge(actor1);
    em.merge(actor2);
    em.getTransaction().commit();
    em.clear();
    Actor actor1AfterMerge=em.find(Actor.class,1);
    Actor actor2AfterMerge=em.find(Actor.class,2);
    assertUpdatedActors(actor1AfterMerge,actor2AfterMerge);
    em.clear();
    em.getTransaction().begin();
    em.remove(actor11);
    em.getTransaction().commit();
    em.getTransaction().begin();
    em.remove(actor22);
    em.getTransaction().commit();
    em.clear();
    Actor actor1AfterDeletion=em.find(Actor.class,1);
    Actor actor2AfterDeletion=em.find(Actor.class,2);
    Assert.assertNull(actor1AfterDeletion);
    Assert.assertNull(actor2AfterDeletion);
  }
 catch (  Exception e) {
    Assert.fail(e.getMessage());
  }
}
Program: 176730
Project: 176730
Buggy source:
public void rollbackBehavior(){
  prepareData();
  em.getTransaction().begin();
  em.persist(actor1);
  em.persist(actor2);
  em.getTransaction().rollback();
  em.clear();
  Actor actor11=em.find(Actor.class,1);
  Actor actor22=em.find(Actor.class,2);
  Assert.assertNull(actor11);
  Assert.assertNull(actor22);
}

Fixed version (ground truth):
@Test public void rollbackBehavior(){
  prepareData();
  em.getTransaction().begin();
  em.persist(actor1);
  em.persist(actor2);
  em.getTransaction().rollback();
  em.clear();
  Actor actor11=em.find(Actor.class,1);
  Actor actor22=em.find(Actor.class,2);
  Assert.assertNull(actor11);
  Assert.assertNull(actor22);
}
Program: 176731
Project: 176731
Buggy source:
@Test public void rollbackBehaviorOnException(){
  prepareData();
  try {
    em.getTransaction().begin();
    em.persist(actor1);
    em.persist(actor2);
    em.getTransaction().commit();
    em.getTransaction().begin();
    actor1.setName("String_Node_Str");
    em.merge(actor1);
    em.merge(null);
    em.getTransaction().commit();
  }
 catch (  Exception e) {
    em.clear();
    Actor actor11=em.find(Actor.class,1);
    Actor actor22=em.find(Actor.class,2);
    Assert.assertNull(actor11);
    Assert.assertNull(actor22);
  }
}

Fixed version (ground truth):
@Test public void rollbackBehaviorOnException(){
  prepareData();
  try {
    em.getTransaction().begin();
    em.persist(actor1);
    em.persist(actor2);
    em.getTransaction().commit();
    em.getTransaction().begin();
    actor1.setName("String_Node_Str");
    actor2.setName("String_Node_Str");
    em.merge(actor1);
    em.merge(null);
    em.merge(actor2);
    em.getTransaction().commit();
  }
 catch (  Exception e) {
    em.clear();
    Actor actor11=em.find(Actor.class,1);
    Actor actor22=em.find(Actor.class,2);
    Assert.assertNotNull(actor11);
    Assert.assertNotNull(actor22);
    Assert.assertEquals("String_Node_Str",actor11.getName());
    Assert.assertNotSame("String_Node_Str",actor22.getName());
  }
}
Program: 176732
Project: 176732
Buggy source:
public void withoutTransaction(){
  prepareData();
  try {
    em.persist(actor1);
    em.persist(actor2);
  }
 catch (  Exception e) {
    Assert.assertTrue(e.getCause().toString().indexOf(NotInTransactionException.class.getSimpleName()) >= 0);
  }
  em.clear();
  Actor actor11=em.find(Actor.class,1);
  Actor actor22=em.find(Actor.class,2);
  Assert.assertNull(actor11);
  Assert.assertNull(actor22);
}

Fixed version (ground truth):
@Test public void withoutTransaction(){
  prepareData();
  try {
    em.persist(actor1);
    em.persist(actor2);
    Assert.fail();
  }
 catch (  Exception e) {
    Assert.assertTrue(e.getMessage().toString().indexOf("String_Node_Str") >= 0);
  }
  em.clear();
  Actor actor11=em.find(Actor.class,1);
  Actor actor22=em.find(Actor.class,2);
  Assert.assertNull(actor11);
  Assert.assertNull(actor22);
  em.getTransaction().begin();
  em.remove(actor1);
  em.remove(actor2);
  em.getTransaction().commit();
}
Program: 176733
Project: 176733
Buggy source:
@Override public void onCommit(){
  onFlush();
  isActive=false;
}

Fixed version (ground truth):
@Override public void onCommit(){
  onFlush();
  nodes.clear();
  nodes=null;
  nodes=new ArrayList<Node>();
  isActive=false;
}
Program: 176734
Project: 176734
Buggy source:
public void commit(){
  doFlush();
  execute();
  isTransactionInProgress=false;
}

Fixed version (ground truth):
public void commit(){
  execute();
  flushManager.commit();
  flushManager.clearFlushStack();
  isTransactionInProgress=false;
}
Program: 176735
Project: 176735
Buggy source:
/** 
 * Release/return connection to pool.
 * @param res jedis resource
 */
void releaseConnection(Jedis res){
  logger.info("String_Node_Str");
  Object poolOrConnection=getConnectionPoolOrConnection();
  if (poolOrConnection instanceof JedisPoolConfig) {
    ((JedisPool)poolOrConnection).returnResource(res);
  }
}

Fixed version (ground truth):
/** 
 * Release/return connection to pool.
 * @param res jedis resource
 */
void releaseConnection(Jedis res){
  logger.info("String_Node_Str");
  Object poolOrConnection=getConnectionPoolOrConnection();
  if (poolOrConnection instanceof JedisPool) {
    ((JedisPool)poolOrConnection).returnResource(res);
  }
}
Program: 176736
Project: 176736
Buggy source:
@Override public void destroy(){
  logger.info("String_Node_Str");
  if (getConnectionPoolOrConnection() != null && getConnectionPoolOrConnection() instanceof JedisPoolConfig) {
    ((JedisPool)getConnectionPoolOrConnection()).destroy();
  }
}

Fixed version (ground truth):
@Override public void destroy(){
  logger.info("String_Node_Str");
  if (getConnectionPoolOrConnection() != null && getConnectionPoolOrConnection() instanceof JedisPool) {
    ((JedisPool)getConnectionPoolOrConnection()).destroy();
  }
}