nus-yam/ex-repair huggingface dataset:
Program: 176605
Project: 176605
Buggy source:
/** 
 * Return name if Idcolumn for cql, returns   {@CassandraConstants.CQL_KEY}if user opted for   {@PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE} otherwise returns JPAColumnName of id attribute.
 * @param m
 * @param externalProperties
 * @return
 */
public static String getIdColumnName(final EntityMetadata m,final Map<String,Object> externalProperties){
  String persistenceUnit=m.getPersistenceUnit();
  PersistenceUnitMetadata persistenceUnitMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(persistenceUnit);
  String autoDdlOption=externalProperties != null ? (String)externalProperties.get(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE) : null;
  if (autoDdlOption == null) {
    autoDdlOption=persistenceUnitMetadata != null ? persistenceUnitMetadata.getProperty(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE) : null;
  }
  return autoDdlOption == null ? ((AbstractAttribute)m.getIdAttribute()).getJPAColumnName() : CassandraConstants.CQL_KEY;
}

Fixed version (ground truth):
/** 
 * Return name if Idcolumn for cql, returns   {@CassandraConstants.CQL_KEY} if user opted for{@PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE} otherwise returnsJPAColumnName of id attribute.
 * @param m
 * @param externalProperties
 * @return
 */
public static String getIdColumnName(final EntityMetadata m,final Map<String,Object> externalProperties){
  String persistenceUnit=m.getPersistenceUnit();
  PersistenceUnitMetadata persistenceUnitMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(persistenceUnit);
  String autoDdlOption=externalProperties != null ? (String)externalProperties.get(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE) : null;
  if (autoDdlOption == null) {
    autoDdlOption=persistenceUnitMetadata != null ? persistenceUnitMetadata.getProperty(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE) : null;
  }
  return autoDdlOption == null ? ((AbstractAttribute)m.getIdAttribute()).getJPAColumnName() : CassandraConstants.CQL_KEY;
}
Program: 176606
Project: 176606
Buggy source:
/** 
 * Populate metadata.
 * @param < X > the generic type
 * @param < T > the generic type
 * @param metadata the metadata
 * @param clazz the clazz
 */
private <X extends Class,T extends Object>void populateMetadata(EntityMetadata metadata,Class<X> clazz,Map puProperties){
  Table table=clazz.getAnnotation(Table.class);
  boolean isEmbeddable=false;
  metadata.setTableName(table.name());
  addNamedNativeQueryMetadata(clazz);
  String schemaStr=table.schema();
  if (schemaStr == null) {
    LOG.error("String_Node_Str" + table.name() + "String_Node_Str");
    throw new InvalidEntityDefinitionException("String_Node_Str" + table.name() + "String_Node_Str");
  }
  MetadataUtils.setSchemaAndPersistenceUnit(metadata,schemaStr,puProperties);
  if (metadata.getPersistenceUnit() != null) {
    MetaModelBuilder<X,T> metaModelBuilder=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(metadata.getPersistenceUnit());
    metaModelBuilder.process(clazz);
    for (    Field f : clazz.getDeclaredFields()) {
      if (f != null && !Modifier.isStatic(f.getModifiers()) && !Modifier.isTransient(f.getModifiers()) && !f.isAnnotationPresent(Transient.class)) {
        metaModelBuilder.construct(clazz,f);
        onIdAttribute(metaModelBuilder,metadata,clazz,f);
        onFamilyType(metadata,clazz,f);
        onJPAColumnMapping(metaModelBuilder,metadata,f);
        addRelationIntoMetadata(clazz,f,metadata);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Populate metadata.
 * @param < X > the generic type
 * @param < T > the generic type
 * @param metadata the metadata
 * @param clazz the clazz
 */
private <X extends Class,T extends Object>void populateMetadata(EntityMetadata metadata,Class<X> clazz,Map puProperties){
  Table table=clazz.getAnnotation(Table.class);
  boolean isEmbeddable=false;
  metadata.setTableName(table.name());
  addNamedNativeQueryMetadata(clazz);
  String schemaStr=table.schema();
  if (StringUtils.isBlank(schemaStr)) {
    LOG.error("String_Node_Str" + table.name() + "String_Node_Str");
    throw new InvalidEntityDefinitionException("String_Node_Str" + table.name() + "String_Node_Str");
  }
  MetadataUtils.setSchemaAndPersistenceUnit(metadata,schemaStr,puProperties);
  if (metadata.getPersistenceUnit() != null) {
    MetaModelBuilder<X,T> metaModelBuilder=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(metadata.getPersistenceUnit());
    metaModelBuilder.process(clazz);
    for (    Field f : clazz.getDeclaredFields()) {
      if (f != null && !Modifier.isStatic(f.getModifiers()) && !Modifier.isTransient(f.getModifiers()) && !f.isAnnotationPresent(Transient.class)) {
        metaModelBuilder.construct(clazz,f);
        onIdAttribute(metaModelBuilder,metadata,clazz,f);
        onFamilyType(metadata,clazz,f);
        onJPAColumnMapping(metaModelBuilder,metadata,f);
        addRelationIntoMetadata(clazz,f,metadata);
      }
    }
  }
}
Program: 176607
Project: 176607
Buggy source:
@Override public List<Object> findByRelation(String colName,Object colValue,Class entityClazz){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClazz);
  Object[] ids=findIdsByColumn(entityMetadata.getSchema(),entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName(),colName,colValue,entityClazz);
  List<Object> resultSet=new ArrayList<Object>();
  if (ids != null) {
    for (    Object id : new HashSet(Arrays.asList(ids))) {
      resultSet.add(find(entityClazz,id));
    }
  }
  return resultSet;
}

Fixed version (ground truth):
@Override public List<Object> findByRelation(String colName,Object colValue,Class entityClazz){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClazz);
  Object[] ids=findIdsByColumn(entityMetadata.getTableName(),colName,colValue);
  List<Object> resultSet=new ArrayList<Object>();
  if (ids != null) {
    for (    Object id : new HashSet(Arrays.asList(ids))) {
      resultSet.add(find(entityClazz,id));
    }
  }
  return resultSet;
}
Program: 176608
Project: 176608
Buggy source:
@Override public Object[] findIdsByColumn(String schemaName,String tableName,String pKeyName,String columnName,Object columnValue,Class entityClazz){
  Object connection=null;
  try {
    connection=getConnection();
    String valueAsStr=PropertyAccessorHelper.getString(columnValue);
    Set<String> results=null;
    if (resource != null && resource.isActive()) {
      Response response=((Transaction)connection).zrangeByScore(getHashKey(tableName,columnName),getDouble(valueAsStr),getDouble(valueAsStr));
      ((Transaction)connection).exec();
      results=(Set<String>)response.get();
    }
 else {
      results=((Jedis)connection).zrangeByScore(getHashKey(tableName,columnName),getDouble(valueAsStr),getDouble(valueAsStr));
    }
    if (results != null) {
      return results.toArray(new Object[0]);
    }
  }
  finally {
    onCleanup(connection);
  }
  return null;
}

Fixed version (ground truth):
public Object[] findIdsByColumn(String tableName,String columnName,Object columnValue){
  Object connection=null;
  try {
    connection=getConnection();
    String valueAsStr=PropertyAccessorHelper.getString(columnValue);
    Set<String> results=null;
    if (resource != null && resource.isActive()) {
      Response response=((Transaction)connection).zrangeByScore(getHashKey(tableName,columnName),getDouble(valueAsStr),getDouble(valueAsStr));
      ((Transaction)connection).exec();
      results=(Set<String>)response.get();
    }
 else {
      results=((Jedis)connection).zrangeByScore(getHashKey(tableName,columnName),getDouble(valueAsStr),getDouble(valueAsStr));
    }
    if (results != null) {
      return results.toArray(new Object[0]);
    }
  }
  finally {
    onCleanup(connection);
  }
  return null;
}
Program: 176609
Project: 176609
Buggy source:
@Override public void delete(Object entity,Object pKey){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entity.getClass());
  String idString=PropertyAccessorHelper.getString(pKey);
  Key key=Key.createKey(entityMetadata.getTableName());
  KeyRange keyRange=new KeyRange(idString,true,idString,true);
  Iterator<KeyValueVersion> iterator=kvStore.storeIterator(Direction.UNORDERED,0,key,keyRange,null);
  List<Operation> deleteOperations=new ArrayList<Operation>();
  while (iterator.hasNext()) {
    KeyValueVersion keyValueVersion=iterator.next();
    List<String> minorKeysComponents=keyValueVersion.getKey().getMinorPath();
    if (minorKeysComponents.size() > 0 && minorKeysComponents.get(minorKeysComponents.size() - 1).endsWith(LOB_SUFFIX)) {
      kvStore.deleteLOB(keyValueVersion.getKey(),DURABILITY_DEFAULT,WRITE_TIMEOUT_SECONDS,TimeUnit.SECONDS);
    }
 else {
      Operation op=kvStore.getOperationFactory().createDelete(keyValueVersion.getKey());
      deleteOperations.add(op);
    }
  }
  execute(deleteOperations);
  getIndexManager().remove(entityMetadata,entity,pKey.toString());
}

Fixed version (ground truth):
@Override public void delete(Object entity,Object pKey){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entity.getClass());
  String idString=PropertyAccessorHelper.getString(pKey);
  Key key=Key.createKey(entityMetadata.getTableName());
  KeyRange keyRange=new KeyRange(idString,true,idString,true);
  Iterator<KeyValueVersion> iterator=kvStore.storeIterator(Direction.UNORDERED,0,key,keyRange,null);
  List<Operation> deleteOperations=new ArrayList<Operation>();
  while (iterator.hasNext()) {
    KeyValueVersion keyValueVersion=iterator.next();
    Key foundKey=keyValueVersion.getKey();
    String foundIdString=foundKey.getMajorPath().get(1);
    List<String> minorKeysComponents=keyValueVersion.getKey().getMinorPath();
    if (minorKeysComponents.size() > 0 && minorKeysComponents.get(minorKeysComponents.size() - 1).endsWith(LOB_SUFFIX)) {
      kvStore.deleteLOB(keyValueVersion.getKey(),DURABILITY_DEFAULT,WRITE_TIMEOUT_SECONDS,TimeUnit.SECONDS);
    }
 else {
      if (idString.equals(foundIdString)) {
        Operation op=kvStore.getOperationFactory().createDelete(foundKey);
        deleteOperations.add(op);
      }
    }
  }
  execute(deleteOperations);
  getIndexManager().remove(entityMetadata,entity,pKey.toString());
}
Program: 176610
Project: 176610
Buggy source:
public void persist(EntityMetadata entityMetadata,Object entity,org.apache.cassandra.thrift.Cassandra.Client conn,List<RelationHolder> rlHolders) throws UnsupportedEncodingException, InvalidRequestException, TException, UnavailableException, TimedOutException, SchemaDisagreementException {
  String query;
  if (entityMetadata.isCounterColumnType()) {
    query=createUpdateQuery(entityMetadata,entity,conn,rlHolders);
  }
 else {
    query=createInsertQuery(entityMetadata,entity,conn,rlHolders);
  }
  conn.execute_cql3_query(ByteBuffer.wrap(query.getBytes(Constants.CHARSET_UTF8)),Compression.NONE,consistencyLevel);
}

Fixed version (ground truth):
public void persist(EntityMetadata entityMetadata,Object entity,org.apache.cassandra.thrift.Cassandra.Client conn,List<RelationHolder> rlHolders) throws UnsupportedEncodingException, InvalidRequestException, TException, UnavailableException, TimedOutException, SchemaDisagreementException {
  String query;
  if (entityMetadata.isCounterColumnType()) {
    query=createUpdateQueryForCounter(entityMetadata,entity,conn,rlHolders);
  }
 else {
    query=createInsertQuery(entityMetadata,entity,conn,rlHolders);
  }
  conn.execute_cql3_query(ByteBuffer.wrap(query.getBytes(Constants.CHARSET_UTF8)),Compression.NONE,consistencyLevel);
}
Program: 176611
Project: 176611
Buggy source:
public String getCqlVersion(){
  if (getDataStore() != null) {
    Properties properties=getDataStore().getConnection() != null ? getDataStore().getConnection().getProperties() : null;
    if (properties != null) {
      String cqlVersion=properties.getProperty(CassandraConstants.CQL_VERSION);
      if (cqlVersion != null) {
        if (cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_3_0) || cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_2_0)) {
          return cqlVersion;
        }
      }
 else {
        log.warn("String_Node_Str");
      }
    }
  }
  return CassandraConstants.CQL_VERSION_2_0;
}

Fixed version (ground truth):
public String getCqlVersion(){
  if (getDataStore() != null) {
    Properties properties=getDataStore().getConnection() != null ? getDataStore().getConnection().getProperties() : null;
    if (properties != null) {
      String cqlVersion=properties.getProperty(CassandraConstants.CQL_VERSION);
      if (cqlVersion != null) {
        if (cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_3_0) || cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_2_0)) {
          return cqlVersion;
        }
 else {
          log.warn("String_Node_Str");
        }
      }
    }
  }
  return CassandraConstants.CQL_VERSION_2_0;
}
Program: 176614
Project: 176614
Buggy source:
/** 
 * On column.
 * @param column the column
 * @param m the m
 * @param entity the entity
 * @param entityType the entity type
 * @param relationNames the relation names
 * @param isWrapReq the is wrap req
 * @param relations the relations
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private Object onColumn(Column column,EntityMetadata m,Object entity,EntityType entityType,List<String> relationNames,boolean isWrapReq,Map<String,Object> relations) throws InstantiationException, IllegalAccessException {
  String thriftColumnName=PropertyAccessorFactory.STRING.fromBytes(String.class,column.getName());
  byte[] thriftColumnValue=column.getValue();
  return populateViaThrift(m,entity,entityType,relationNames,relations,thriftColumnName,thriftColumnValue);
}

Fixed version (ground truth):
/** 
 * On column.
 * @param column the column
 * @param m the m
 * @param entity the entity
 * @param entityType the entity type
 * @param relationNames the relation names
 * @param isWrapReq the is wrap req
 * @param relations the relations
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private Object onColumn(Column column,EntityMetadata m,Object entity,EntityType entityType,List<String> relationNames,boolean isWrapReq,Map<String,Object> relations) throws InstantiationException, IllegalAccessException {
  String thriftColumnName=PropertyAccessorFactory.STRING.fromBytes(String.class,column.getName());
  byte[] thriftColumnValue=column.getValue();
  if (m.isCounterColumnType()) {
    LongAccessor accessor=new LongAccessor();
    Long value=accessor.fromBytes(Long.class,column.getValue());
    return populateViaThrift(m,entity,entityType,relationNames,relations,thriftColumnName,value.toString());
  }
  return populateViaThrift(m,entity,entityType,relationNames,relations,thriftColumnName,thriftColumnValue);
}
Program: 176616
Project: 176616
Buggy source:
public void buildSetClauseForCounters(StringBuilder builder,String field,Object value){
  builder=ensureCase(builder,field);
  builder.append(EQ_CLAUSE);
  builder=ensureCase(builder,field);
  builder.append(INCR_COUNTER);
  appendValue(builder,value.getClass(),value,false);
  builder.append(COMMA_STR);
}

Fixed version (ground truth):
/** 
 * Builds set clause for a given counter field.
 * @param builder
 * @param field
 * @param value
 */
public void buildSetClauseForCounters(StringBuilder builder,String field,Object value){
  builder=ensureCase(builder,field);
  builder.append(EQ_CLAUSE);
  builder=ensureCase(builder,field);
  builder.append(INCR_COUNTER);
  appendValue(builder,value.getClass(),value,false);
  builder.append(COMMA_STR);
}
Program: 176617
Project: 176617
Buggy source:
public void buildWhereClause(StringBuilder builder,String field,Object value,String clause){
  builder=ensureCase(builder,field);
  builder.append(clause);
  appendValue(builder,value.getClass(),value,false);
  builder.append(AND_CLAUSE);
}

Fixed version (ground truth):
/** 
 * Build where clause with given clause.
 * @param builder
 * @param field
 * @param value
 * @param clause
 */
public void buildWhereClause(StringBuilder builder,String field,Object value,String clause){
  builder=ensureCase(builder,field);
  builder.append(clause);
  appendValue(builder,value.getClass(),value,false);
  builder.append(AND_CLAUSE);
}
Program: 176618
Project: 176618
Buggy source:
/** 
 * Prepare data.
 * @param rowKey the row key
 * @param age the age
 * @return the person
 */
protected PersonCassandra prepareData(String rowKey,int age){
  PersonCassandra o=new PersonCassandra();
  o.setPersonId(rowKey);
  o.setPersonName("String_Node_Str");
  o.setAge(age);
  o.setDay(Day.THURSDAY);
  return o;
}

Fixed version (ground truth):
/** 
 * Prepare data.
 * @param rowKey the row key
 * @param age the age
 * @return the person
 */
protected PersonCassandra prepareData(String rowKey,int age){
  PersonCassandra o=new PersonCassandra();
  o.setPersonId(rowKey);
  o.setPersonName("String_Node_Str");
  o.setAge(age);
  o.setDay(Day.THURSDAY);
  o.setMonth(Month.APRIL);
  return o;
}
Program: 176621
Project: 176621
Buggy source:
private void execute(List<Operation> batch){
  try {
    kvStore.execute(batch);
  }
 catch (  DurabilityException e) {
    log.error(e);
    throw new PersistenceException("String_Node_Str",e);
  }
catch (  OperationExecutionException e) {
    log.error(e);
    throw new PersistenceException("String_Node_Str",e);
  }
catch (  FaultException e) {
    log.error(e);
    throw new PersistenceException("String_Node_Str",e);
  }
 finally {
    batch.clear();
  }
}

Fixed version (ground truth):
private void execute(List<Operation> batch){
  if (batch != null && !batch.isEmpty()) {
    try {
      kvStore.execute(batch);
    }
 catch (    DurabilityException e) {
      log.error(e);
      throw new PersistenceException("String_Node_Str",e);
    }
catch (    OperationExecutionException e) {
      log.error(e);
      throw new PersistenceException("String_Node_Str",e);
    }
catch (    FaultException e) {
      log.error(e);
      throw new PersistenceException("String_Node_Str",e);
    }
 finally {
      batch.clear();
    }
  }
}
Program: 176622
Project: 176622
Buggy source:
public <E>List<E> executeQuery(Class<E> entityClass,OracleNoSQLQueryInterpreter interpreter){
  List<E> results=new ArrayList<E>();
  Set<Object> primaryKeys=null;
  if (!interpreter.getClauseQueue().isEmpty()) {
    primaryKeys=((OracleNoSQLInvertedIndexer)getIndexManager().getIndexer()).executeQuery(interpreter,entityClass);
  }
 else {
    EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClass);
    ArrayList<String> majorComponents=new ArrayList<String>();
    majorComponents.add(m.getTableName());
    Key key=Key.createKey(majorComponents);
    Iterator<KeyValueVersion> iterator=kvStore.storeIterator(Direction.UNORDERED,0,key,null,null);
    Set<Object> keySet=new HashSet<Object>();
    while (iterator.hasNext()) {
      KeyValueVersion keyValueVersion=iterator.next();
      String majorKeySecondPart=keyValueVersion.getKey().getMajorPath().get(1);
      keySet.add(majorKeySecondPart);
    }
    primaryKeys=keySet;
  }
  results=findAll(entityClass,interpreter.getSelectColumns(),primaryKeys.toArray());
  return results;
}

Fixed version (ground truth):
public <E>List<E> executeQuery(Class<E> entityClass,OracleNoSQLQueryInterpreter interpreter,Set<Object> primaryKeys){
  List<E> results=new ArrayList<E>();
  if (primaryKeys == null) {
    primaryKeys=new HashSet<Object>();
  }
  if (!interpreter.getClauseQueue().isEmpty()) {
    primaryKeys.addAll(((OracleNoSQLInvertedIndexer)getIndexManager().getIndexer()).executeQuery(interpreter,entityClass));
  }
 else {
    EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClass);
    ArrayList<String> majorComponents=new ArrayList<String>();
    majorComponents.add(m.getTableName());
    Key key=Key.createKey(majorComponents);
    Iterator<KeyValueVersion> iterator=kvStore.storeIterator(Direction.UNORDERED,0,key,null,null);
    Set<Object> keySet=new HashSet<Object>();
    while (iterator.hasNext()) {
      KeyValueVersion keyValueVersion=iterator.next();
      String majorKeySecondPart=keyValueVersion.getKey().getMajorPath().get(1);
      keySet.add(majorKeySecondPart);
    }
    primaryKeys.addAll(keySet);
  }
  results=findAll(entityClass,interpreter.getSelectColumns(),primaryKeys.toArray());
  return results;
}
Program: 176624
Project: 176624
Buggy source:
@Override protected List<Object> populateEntities(EntityMetadata m,Client client){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  List<Object> results=new ArrayList<Object>();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  String indexerClass=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(m.getPersistenceUnit()).getProperties().getProperty(PersistenceProperties.KUNDERA_INDEXER_CLASS);
  ClientMetadata clientMetadata=KunderaMetadata.INSTANCE.getClientMetadata(m.getPersistenceUnit());
  if (clientMetadata.getIndexImplementor() != null && client.getIndexManager().getIndexer().getClass().equals(LuceneIndexer.class)) {
    results=populateUsingLucene(m,client,results);
  }
 else {
    OracleNoSQLQueryInterpreter interpreter=translateQuery(getKunderaQuery().getFilterClauseQueue(),m);
    results=(List<Object>)((OracleNoSQLClient)client).executeQuery(m.getEntityClazz(),interpreter);
  }
  return results;
}

Fixed version (ground truth):
@Override protected List<Object> populateEntities(EntityMetadata m,Client client){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  Set<Object> results=new HashSet<Object>();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  String indexerClass=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(m.getPersistenceUnit()).getProperties().getProperty(PersistenceProperties.KUNDERA_INDEXER_CLASS);
  ClientMetadata clientMetadata=KunderaMetadata.INSTANCE.getClientMetadata(m.getPersistenceUnit());
  OracleNoSQLQueryInterpreter interpreter=translateQuery(getKunderaQuery().getFilterClauseQueue(),m);
  Set<Object> resultsFromIdSearch=new HashSet<Object>();
  if (interpreter.isFindById()) {
    Object entity=client.find(m.getEntityClazz(),interpreter.getRowKey());
    resultsFromIdSearch.add(entity);
    if (interpreter.getOperatorWithRowKey() == null) {
      List<Object> output=new ArrayList<Object>();
      output.addAll(resultsFromIdSearch);
      return output;
    }
  }
  if (client.getIndexManager().getIndexer().getClass().equals(LuceneIndexer.class)) {
    results.addAll(populateUsingLucene(m,client,null));
  }
 else {
    results.addAll((List<Object>)((OracleNoSQLClient)client).executeQuery(m.getEntityClazz(),interpreter,null));
  }
  List<Object> output=new ArrayList<Object>();
  output.addAll(results);
  return output;
}
Program: 176625
Project: 176625
Buggy source:
private OracleNoSQLQueryInterpreter translateQuery(Queue clauseQueue,EntityMetadata entityMetadata){
  OracleNoSQLQueryInterpreter interpreter=new OracleNoSQLQueryInterpreter(getColumns(getKunderaQuery().getResult(),entityMetadata));
  interpreter.setClauseQueue(clauseQueue);
  return interpreter;
}

Fixed version (ground truth):
private OracleNoSQLQueryInterpreter translateQuery(Queue clauseQueue,EntityMetadata entityMetadata){
  OracleNoSQLQueryInterpreter interpreter=new OracleNoSQLQueryInterpreter(getColumns(getKunderaQuery().getResult(),entityMetadata));
  interpreter.setClauseQueue(clauseQueue);
  String operatorWithIdClause=null;
  boolean idClauseFound=false;
  for (  Object clause : clauseQueue) {
    if (clause.getClass().isAssignableFrom(FilterClause.class) && !idClauseFound) {
      String columnName=((FilterClause)clause).getProperty();
      if (columnName.equals(((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName())) {
        interpreter.setFindById(true);
        interpreter.setRowKey(((FilterClause)clause).getValue());
        idClauseFound=true;
      }
    }
 else     if (clause instanceof String) {
      operatorWithIdClause=clause.toString();
    }
    if (idClauseFound && operatorWithIdClause != null) {
      break;
    }
  }
  interpreter.setOperatorWithRowKey(operatorWithIdClause);
  return interpreter;
}
Program: 176626
Project: 176626
Buggy source:
/** 
 * Sets parameter value into filterClause, depending upon   {@link Type}
 * @param name parameter name.
 * @param value parameter value.
 */
private void setParameterValue(String name,Object value){
  if (typedParameter != null) {
    FilterClause clause=typedParameter.getParameters().get(name);
    if (clause != null) {
      clause.setValue(value);
    }
 else {
      if (typedParameter.getUpdateParameters() != null) {
        UpdateClause updateClause=typedParameter.getUpdateParameters().get(name);
        updateClause.setValue(value);
      }
 else {
        logger.error("String_Node_Str");
        throw new QueryHandlerException("String_Node_Str" + name + "String_Node_Str");
      }
    }
  }
 else {
    throw new QueryHandlerException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Sets parameter value into filterClause, depending upon   {@link Type}
 * @param name parameter name.
 * @param value parameter value.
 */
private void setParameterValue(String name,Object value){
  if (typedParameter != null) {
    FilterClause clause=typedParameter.getParameters() != null ? typedParameter.getParameters().get(name) : null;
    if (clause != null) {
      clause.setValue(value);
    }
 else {
      if (typedParameter.getUpdateParameters() != null) {
        UpdateClause updateClause=typedParameter.getUpdateParameters().get(name);
        updateClause.setValue(value);
      }
 else {
        logger.error("String_Node_Str");
        throw new QueryHandlerException("String_Node_Str" + name + "String_Node_Str");
      }
    }
  }
 else {
    throw new QueryHandlerException("String_Node_Str");
  }
}
Program: 176627
Project: 176627
Buggy source:
/** 
 * constructor using fields.
 * @param persistenceUnit the persistence unit
 * @param externalProperties
 */
protected CassandraClientBase(String persistenceUnit,Map<String,Object> externalProperties){
  this.externalProperties=externalProperties;
  this.cqlClient=new CQLClient();
  setBatchSize(persistenceUnit,this.externalProperties);
  cqlVersion=externalProperties != null ? (String)externalProperties.get(CassandraConstants.CQL_VERSION) : null;
  cqlVersion=cqlVersion == null ? (CassandraPropertyReader.csmd != null ? CassandraPropertyReader.csmd.getCqlVersion() : CassandraConstants.CQL_VERSION_3_0) : cqlVersion;
  this.isCQLEnabled=cqlVersion.equals(CassandraConstants.CQL_VERSION_3_0);
}

Fixed version (ground truth):
/** 
 * constructor using fields.
 * @param persistenceUnit the persistence unit
 * @param externalProperties
 */
protected CassandraClientBase(String persistenceUnit,Map<String,Object> externalProperties){
  this.externalProperties=externalProperties;
  this.cqlClient=new CQLClient();
  setBatchSize(persistenceUnit,this.externalProperties);
  cqlVersion=externalProperties != null ? (String)externalProperties.get(CassandraConstants.CQL_VERSION) : null;
  cqlVersion=cqlVersion == null ? (CassandraPropertyReader.csmd != null ? CassandraPropertyReader.csmd.getCqlVersion() : CassandraConstants.CQL_VERSION_2_0) : cqlVersion;
  this.isCQLEnabled=cqlVersion.equals(CassandraConstants.CQL_VERSION_3_0);
}
Program: 176628
Project: 176628
Buggy source:
public String getCqlVersion(){
  if (getDataStore() != null) {
    Properties properties=getDataStore().getConnection() != null ? getDataStore().getConnection().getProperties() : null;
    if (properties != null) {
      String cqlVersion=properties.getProperty(CassandraConstants.CQL_VERSION);
      if (cqlVersion != null) {
        if (cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_3_0) || cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_2_0)) {
          return cqlVersion;
        }
      }
 else {
        log.warn("String_Node_Str");
      }
    }
  }
  return CassandraConstants.CQL_VERSION_3_0;
}

Fixed version (ground truth):
public String getCqlVersion(){
  if (getDataStore() != null) {
    Properties properties=getDataStore().getConnection() != null ? getDataStore().getConnection().getProperties() : null;
    if (properties != null) {
      String cqlVersion=properties.getProperty(CassandraConstants.CQL_VERSION);
      if (cqlVersion != null) {
        if (cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_3_0) || cqlVersion.equalsIgnoreCase(CassandraConstants.CQL_VERSION_2_0)) {
          return cqlVersion;
        }
      }
 else {
        log.warn("String_Node_Str");
      }
    }
  }
  return CassandraConstants.CQL_VERSION_2_0;
}
Program: 176630
Project: 176630
Buggy source:
private void setFieldValueViaCQL(Object entity,Object thriftColumnValue,Attribute attribute){
  if (attribute != null) {
    try {
      if (((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(String.class) || ((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(char.class) || ((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(Character.class)) {
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),new String((byte[])thriftColumnValue));
      }
 else       if (((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(short.class)) {
        IntegerAccessor accessor=new IntegerAccessor();
        Integer value=accessor.fromBytes(short.class,(byte[])thriftColumnValue);
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),String.valueOf(value));
      }
 else       if (((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(byte.class)) {
        IntegerAccessor accessor=new IntegerAccessor();
        Integer value=accessor.fromBytes(byte.class,(byte[])thriftColumnValue);
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),String.valueOf(value));
      }
 else {
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),(byte[])thriftColumnValue);
      }
    }
 catch (    PropertyAccessException pae) {
      log.warn(pae.getMessage());
    }
  }
}

Fixed version (ground truth):
private void setFieldValueViaCQL(Object entity,Object thriftColumnValue,Attribute attribute){
  if (attribute != null) {
    try {
      if (((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(String.class) || ((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(char.class) || ((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(Character.class)) {
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),new String((byte[])thriftColumnValue));
      }
 else       if (((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(short.class) || ((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(Short.class)) {
        IntegerAccessor accessor=new IntegerAccessor();
        Integer value=accessor.fromBytes(short.class,(byte[])thriftColumnValue);
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),String.valueOf(value));
      }
 else       if (((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(byte.class) || ((AbstractAttribute)attribute).getBindableJavaType().isAssignableFrom(Byte.class)) {
        IntegerAccessor accessor=new IntegerAccessor();
        Integer value=accessor.fromBytes(byte.class,(byte[])thriftColumnValue);
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),String.valueOf(value));
      }
 else {
        PropertyAccessorHelper.set(entity,(Field)attribute.getJavaMember(),(byte[])thriftColumnValue);
      }
    }
 catch (    PropertyAccessException pae) {
      log.warn(pae.getMessage());
    }
  }
}
Program: 176631
Project: 176631
Buggy source:
@Override public void destroy(){
  if (indexManager != null) {
    indexManager.close();
  }
  if (schemaManager != null) {
    getSchemaManager(externalProperties).dropSchema();
  }
  schemaManager=null;
  externalProperties=null;
}

Fixed version (ground truth):
@Override public void destroy(){
  if (indexManager != null) {
    indexManager.close();
  }
  if (schemaManager != null) {
    schemaManager.dropSchema();
  }
  schemaManager=null;
  externalProperties=null;
}
Program: 176632
Project: 176632
Buggy source:
/** 
 * Appends value to builder object for given class type
 * @param builder string builder.
 * @param fieldClazz field class.
 * @param value value to be appended.
 * @param isPresent if field is present.
 * @return true, if value is not null else false.
 */
public boolean appendValue(StringBuilder builder,Class fieldClazz,Object value,boolean isPresent){
  if (value != null) {
    isPresent=true;
    if (fieldClazz.isAssignableFrom(String.class) || isDate(fieldClazz) || fieldClazz.isAssignableFrom(char.class)|| fieldClazz.isAssignableFrom(Character.class)|| value instanceof Enum|| fieldClazz.isAssignableFrom(Float.class)) {
      builder.append("String_Node_Str");
      if (isDate(fieldClazz)) {
        builder.append(PropertyAccessorFactory.getPropertyAccessor(fieldClazz).toString(value));
      }
 else       if (value instanceof Enum) {
        builder.append(((Enum)value).name());
      }
 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)|| value instanceof Enum|| fieldClazz.isAssignableFrom(Float.class)|| fieldClazz.isAssignableFrom(float.class)|| fieldClazz.isAssignableFrom(Double.class)|| fieldClazz.isAssignableFrom(double.class)) {
      builder.append("String_Node_Str");
      if (isDate(fieldClazz)) {
        builder.append(PropertyAccessorFactory.getPropertyAccessor(fieldClazz).toString(value));
      }
 else       if (value instanceof Enum) {
        builder.append(((Enum)value).name());
      }
 else {
        builder.append(value);
      }
      builder.append("String_Node_Str");
    }
 else {
      builder.append(value);
    }
  }
  return isPresent;
}
Program: 176633
Project: 176633
Buggy source:
@Override public void destroy(){
  if (indexManager != null) {
    indexManager.close();
  }
  if (schemaManager != null) {
    getSchemaManager(externalProperties).dropSchema();
  }
  schemaManager=null;
  externalProperties=null;
}

Fixed version (ground truth):
@Override public void destroy(){
  if (indexManager != null) {
    indexManager.close();
  }
  if (schemaManager != null) {
    schemaManager.dropSchema();
  }
  schemaManager=null;
  externalProperties=null;
}
Program: 176634
Project: 176634
Buggy source:
/** 
 * adds join column name to the table Info of entity.
 * @param joinColumn
 * @param targetTableInfo
 * @param targetTableInfos
 */
private void addJoinColumnToInfo(String joinColumn,TableInfo targetTableInfo,List<TableInfo> targetTableInfos,EntityMetadata m){
  if (!targetTableInfos.isEmpty() && targetTableInfos.contains(targetTableInfo)) {
    int idx=targetTableInfos.indexOf(targetTableInfo);
    targetTableInfo=targetTableInfos.get(idx);
    if (!targetTableInfo.getColumnMetadatas().contains(getJoinColumn(joinColumn,m.getIdAttribute().getBindableJavaType()))) {
      targetTableInfo.addColumnInfo(getJoinColumn(joinColumn,m.getIdAttribute().getBindableJavaType()));
    }
  }
 else {
    if (!targetTableInfo.getColumnMetadatas().contains(getJoinColumn(joinColumn,m.getIdAttribute().getBindableJavaType()))) {
      targetTableInfo.addColumnInfo(getJoinColumn(joinColumn,m.getIdAttribute().getBindableJavaType()));
    }
    targetTableInfos.add(targetTableInfo);
  }
}

Fixed version (ground truth):
/** 
 * adds join column name to the table Info of entity.
 * @param joinColumn
 * @param targetTableInfo
 * @param targetTableInfos
 */
private void addJoinColumnToInfo(String joinColumn,TableInfo targetTableInfo,List<TableInfo> targetTableInfos,EntityMetadata m){
  if (!targetTableInfos.isEmpty() && targetTableInfos.contains(targetTableInfo)) {
    int idx=targetTableInfos.indexOf(targetTableInfo);
    targetTableInfo=targetTableInfos.get(idx);
    if (!targetTableInfo.getColumnMetadatas().contains(getJoinColumn(joinColumn))) {
      targetTableInfo.addColumnInfo(getJoinColumn(joinColumn));
    }
  }
 else {
    if (!targetTableInfo.getColumnMetadatas().contains(getJoinColumn(joinColumn))) {
      targetTableInfo.addColumnInfo(getJoinColumn(joinColumn));
    }
    targetTableInfos.add(targetTableInfo);
  }
}
Program: 176635
Project: 176635
Buggy source:
/** 
 * getJoinColumn method return ColumnInfo for the join column
 * @param columnType
 * @param String joinColumnName.
 * @return ColumnInfo object columnInfo.
 */
private ColumnInfo getJoinColumn(String joinColumnName,Class columnType){
  ColumnInfo columnInfo=new ColumnInfo();
  columnInfo.setColumnName(joinColumnName);
  columnInfo.setIndexable(true);
  columnInfo.setType(columnType);
  return columnInfo;
}

Fixed version (ground truth):
/** 
 * getJoinColumn method return ColumnInfo for the join column
 * @param columnType
 * @param String joinColumnName.
 * @return ColumnInfo object columnInfo.
 */
private ColumnInfo getJoinColumn(String joinColumnName){
  ColumnInfo columnInfo=new ColumnInfo();
  columnInfo.setColumnName(joinColumnName);
  columnInfo.setIndexable(true);
  return columnInfo;
}
Program: 176637
Project: 176637
Buggy source:
/** 
 * Sets the connection pool or connection.      
 */
protected void setConnectionPoolOrConnection(Object connectionPoolOrConnection){
  this.connectionPoolOrConnection=connectionPoolOrConnection;
}

Fixed version (ground truth):
/** 
 * Sets the connection pool or connection.
 */
protected void setConnectionPoolOrConnection(Object connectionPoolOrConnection){
  this.connectionPoolOrConnection=connectionPoolOrConnection;
}
Program: 176638
Project: 176638
Buggy source:
protected void unload(){
  if (client != null) {
    client.close();
    client=null;
  }
}

Fixed version (ground truth):
protected void unload(){
  if (client != null) {
    client.close();
    client=null;
  }
  externalProperties=null;
}
Program: 176639
Project: 176639
Buggy source:
/** 
 * @param puProperties
 */
protected void setExternalProperties(Map<String,Object> puProperties){
  if (this.externalProperties == null) {
    this.externalProperties=puProperties;
  }
}

Fixed version (ground truth):
/** 
 * @param puProperties
 */
protected void setExternalProperties(Map<String,Object> puProperties){
  this.externalProperties=puProperties;
}
Program: 176640
Project: 176640
Buggy source:
/** 
 * Retrieves associated entities from secondary index. There are two alternatives here: 1. Via running Lucene query into Lucene powered secondary index. 2. Searching into a secondary index by custom secondary index class provided by user.
 * @see PersistenceProperties#KUNDERA_INDEX_HOME_DIR
 * @see PersistenceProperties#KUNDERA_INDEXER_CLASS TODO: Which secondary index to use should be transparent. All we should bother about is indexer.index(), indexer.search() etc. 
 */
private List getAssociatedEntitiesFromIndex(Object entity,Object entityId,Class<?> childClass,Client childClient){
  List associatedEntities;
  IndexManager indexManager=childClient.getIndexManager();
  Map<String,Object> results=indexManager != null ? indexManager.search(entity.getClass(),childClass,entityId) : new HashMap<String,Object>();
  Set rsSet=results != null ? new HashSet(results.values()) : new HashSet();
  if (childClass.equals(entity.getClass())) {
    associatedEntities=(List<Object>)childClient.findAll(childClass,rsSet.toArray(new Object[]{}));
  }
 else {
    associatedEntities=(List<Object>)childClient.findAll(childClass,rsSet.toArray(new Object[]{}));
  }
  return associatedEntities;
}

Fixed version (ground truth):
/** 
 * Retrieves associated entities from secondary index. There are two alternatives here: 1. Via running Lucene query into Lucene powered secondary index. 2. Searching into a secondary index by custom secondary index class provided by user.
 * @see PersistenceProperties#KUNDERA_INDEX_HOME_DIR
 * @see PersistenceProperties#KUNDERA_INDEXER_CLASS TODO: Which secondary index to use should be transparent. All we should bother about is indexer.index(), indexer.search() etc.
 */
private List getAssociatedEntitiesFromIndex(Object entity,Object entityId,Class<?> childClass,Client childClient){
  List associatedEntities;
  IndexManager indexManager=childClient.getIndexManager();
  Map<String,Object> results=indexManager != null ? indexManager.search(entity.getClass(),childClass,entityId) : new HashMap<String,Object>();
  Set rsSet=results != null ? new HashSet(results.values()) : new HashSet();
  if (childClass.equals(entity.getClass())) {
    associatedEntities=(List<Object>)childClient.findAll(childClass,rsSet.toArray(new Object[]{}));
  }
 else {
    associatedEntities=(List<Object>)childClient.findAll(childClass,rsSet.toArray(new Object[]{}));
  }
  return associatedEntities;
}
Program: 176641
Project: 176641
Buggy source:
private void onLookUp(PersistenceUnitTransactionType transactionType){
  if (transactionType != null && transactionType.equals(PersistenceUnitTransactionType.JTA)) {
    if (this.entityTransaction == null) {
      this.entityTransaction=new KunderaEntityTransaction(this);
    }
    Context ctx;
    try {
      ctx=new InitialContext();
      this.utx=(UserTransaction)ctx.lookup("String_Node_Str");
      if (this.utx == null) {
        throw new KunderaException("String_Node_Str");
      }
      if (!(this.utx instanceof KunderaJTAUserTransaction)) {
        throw new KunderaException("String_Node_Str" + KunderaJTAUserTransaction.class.getName() + "String_Node_Str"+ this.utx.getClass());
      }
      if (!this.entityTransaction.isActive()) {
        this.entityTransaction.begin();
      }
      this.setFlushMode(FlushModeType.COMMIT);
      ((KunderaJTAUserTransaction)this.utx).setImplementor(this);
    }
 catch (    NamingException e) {
      logger.error("String_Node_Str",e);
      throw new KunderaException(e);
    }
  }
}

Fixed version (ground truth):
private void onLookUp(PersistenceUnitTransactionType transactionType){
  if (transactionType != null && transactionType.equals(PersistenceUnitTransactionType.JTA)) {
    if (this.entityTransaction == null) {
      this.entityTransaction=new KunderaEntityTransaction(this);
    }
    Context ctx;
    try {
      ctx=new InitialContext();
      this.utx=(UserTransaction)ctx.lookup("String_Node_Str");
      if (this.utx == null) {
        throw new KunderaException("String_Node_Str");
      }
      if (!(this.utx instanceof KunderaJTAUserTransaction)) {
        throw new KunderaException("String_Node_Str" + KunderaJTAUserTransaction.class.getName() + "String_Node_Str"+ this.utx.getClass());
      }
      if (!this.entityTransaction.isActive()) {
        this.entityTransaction.begin();
        this.setFlushMode(FlushModeType.COMMIT);
        ((KunderaJTAUserTransaction)this.utx).setImplementor(this);
      }
    }
 catch (    NamingException e) {
      logger.error("String_Node_Str",e);
      throw new KunderaException(e);
    }
  }
}
Program: 176642
Project: 176642
Buggy source:
void setImplementor(ResourceManager implementor){
  implementors.add(implementor);
}

Fixed version (ground truth):
void setImplementor(ResourceManager implementor){
  if (!implementors.contains(implementor)) {
    implementors.add(implementor);
  }
}
Program: 176643
Project: 176643
Buggy source:
@Test public void testConcurrentPersist() throws NotSupportedException, SystemException, NamingException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
  userTransaction=(UserTransaction)initialContext.lookup("String_Node_Str");
  userTransaction.begin();
  for (i=0; i < 1; i++) {
    Runnable r=onExecute();
    r.run();
  }
  userTransaction.commit();
  userTransaction.begin();
  for (i=0; i < 1; i++) {
    EntityManager em1=emf.createEntityManager();
    Assert.assertNotNull(em1.find(PersonnelOToOFKEntityJTA.class,"String_Node_Str" + i));
  }
}

Fixed version (ground truth):
@Test public void testConcurrentPersist() throws NotSupportedException, SystemException, NamingException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
  userTransaction=(UserTransaction)initialContext.lookup("String_Node_Str");
  userTransaction.begin();
  for (i=0; i < 100; i++) {
    Runnable r=onExecute();
    r.run();
  }
  userTransaction.commit();
  userTransaction.begin();
  for (i=0; i < 100; i++) {
    EntityManager em1=emf.createEntityManager();
    Assert.assertNotNull(em1.find(PersonnelOToOFKEntityJTA.class,"String_Node_Str" + i));
  }
}
Program: 176644
Project: 176644
Buggy source:
@Override public final void process(final Class<?> entityClass,EntityMetadata metadata){
  EntityListeners entityListeners=(EntityListeners)entityClass.getAnnotation(EntityListeners.class);
  if (entityListeners != null) {
    Class<?>[] entityListenerClasses=entityListeners.value();
    if (entityListenerClasses != null) {
      for (      Class<?> entityListener : entityListenerClasses) {
        try {
          entityListener.getConstructor();
        }
 catch (        NoSuchMethodException nsme) {
          throw new MetamodelLoaderException("String_Node_Str" + entityListener.getName() + "String_Node_Str");
        }
        for (        Method method : entityListener.getDeclaredMethods()) {
          List<Class<?>> jpaAnnotations=getValidJPAAnnotationsFromMethod(entityListener,method,1);
          for (          Class<?> jpaAnnotation : jpaAnnotations) {
            CallbackMethod callBackMethod=new ExternalCallbackMethod(entityListener,method);
            addCallBackMethod(metadata,jpaAnnotation,callBackMethod);
          }
        }
      }
    }
  }
  for (  Method method : entityClass.getDeclaredMethods()) {
    List<Class<?>> jpaAnnotations=getValidJPAAnnotationsFromMethod(entityClass,method,0);
    for (    Class<?> jpaAnnotation : jpaAnnotations) {
      CallbackMethod callbackMethod=new InternalCallbackMethod(metadata,method);
      addCallBackMethod(metadata,jpaAnnotation,callbackMethod);
    }
  }
}

Fixed version (ground truth):
@Override public final void process(final Class<?> entityClass,EntityMetadata metadata){
  EntityListeners entityListeners=(EntityListeners)entityClass.getAnnotation(EntityListeners.class);
  if (entityListeners != null) {
    Class<?>[] entityListenerClasses=entityListeners.value();
    if (entityListenerClasses != null) {
      for (      Class<?> entityListener : entityListenerClasses) {
        try {
          entityListener.getConstructor();
        }
 catch (        NoSuchMethodException nsme) {
          throw new MetamodelLoaderException("String_Node_Str" + entityListener.getName() + "String_Node_Str");
        }
        for (        Method method : entityListener.getDeclaredMethods()) {
          List<Class<?>> jpaAnnotations=getValidJPAAnnotationsFromMethod(entityListener,method,1,entityClass);
          for (          Class<?> jpaAnnotation : jpaAnnotations) {
            CallbackMethod callBackMethod=new ExternalCallbackMethod(entityListener,method);
            addCallBackMethod(metadata,jpaAnnotation,callBackMethod);
          }
        }
      }
    }
  }
  for (  Method method : entityClass.getDeclaredMethods()) {
    List<Class<?>> jpaAnnotations=getValidJPAAnnotationsFromMethod(entityClass,method,0,entityClass);
    for (    Class<?> jpaAnnotation : jpaAnnotations) {
      CallbackMethod callbackMethod=new InternalCallbackMethod(metadata,method);
      addCallBackMethod(metadata,jpaAnnotation,callbackMethod);
    }
  }
}