nus-yam/ex-repair huggingface dataset:
Program: 176994
Project: 176994
Buggy source:
@Override public List<EnhanceEntity> populateRelation(EntityMetadata m,List<String> relationNames,boolean isParent,Client client){
  List<EnhanceEntity> ls=null;
  if (!isParent) {
    String sqlQuery=null;
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      sqlQuery=getSqlQueryFromJPA(m,relationNames,null);
    }
 else {
      Set<String> rSet=fetchDataFromLucene(client);
      if (rSet != null && !rSet.isEmpty()) {
        filter="String_Node_Str";
      }
      sqlQuery=getSqlQueryFromJPA(m,relationNames,rSet);
    }
    ls=populateEnhanceEntities(m,relationNames,client,sqlQuery);
  }
 else {
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      try {
        List entities=((HibernateClient)client).find(jpaQuery,new ArrayList<String>(),m.getEntityClazz());
        ls=new ArrayList<EnhanceEntity>(entities.size());
        transform(m,ls,entities);
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + e.getMessage());
        throw new QueryHandlerException(e.getMessage());
      }
    }
 else {
      ls=onAssociationUsingLucene(m,client,ls);
    }
  }
  return ls;
}

Fixed version (ground truth):
@Override public List<EnhanceEntity> populateRelation(EntityMetadata m,List<String> relationNames,boolean isParent,Client client){
  List<EnhanceEntity> ls=null;
  if (!isParent) {
    String sqlQuery=null;
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      sqlQuery=getSqlQueryFromJPA(m,relationNames,null);
    }
 else {
      Set<String> rSet=fetchDataFromLucene(client);
      if (rSet != null && !rSet.isEmpty()) {
        filter="String_Node_Str";
      }
      sqlQuery=getSqlQueryFromJPA(m,relationNames,rSet);
    }
    ls=populateEnhanceEntities(m,relationNames,client,sqlQuery);
  }
 else {
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      try {
        List entities=((HibernateClient)client).find(jpaQuery,new ArrayList<String>(),m);
        ls=new ArrayList<EnhanceEntity>(entities.size());
        transform(m,ls,entities);
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + e.getMessage());
        throw new QueryHandlerException(e.getMessage());
      }
    }
 else {
      ls=onAssociationUsingLucene(m,client,ls);
    }
  }
  return ls;
}
Program: 176995
Project: 176995
Buggy source:
protected List<Object> populateEntities(EntityMetadata m,Client client){
  log.debug("String_Node_Str");
  List<Object> result=null;
  ((RDBMSEntityReader)getReader()).setConditions(getKunderaQuery().getFilterClauseQueue());
  ((RDBMSEntityReader)getReader()).setFilter(getKunderaQuery().getFilter());
  try {
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      List<String> relations=new ArrayList<String>();
      List r=((HibernateClient)client).find(((RDBMSEntityReader)getReader()).getSqlQueryFromJPA(m,relations,null),relations,m.getEntityClazz());
      result=new ArrayList<Object>(r.size());
      for (      Object o : r) {
        Class clazz=m.getEntityClazz();
        if (!o.getClass().isAssignableFrom(m.getEntityClazz())) {
          o=((Object[])o)[0];
        }
        result.add(o);
      }
    }
 else {
      result=populateUsingLucene(m,client,result);
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
  if (result != null && !result.isEmpty()) {
    persistenceDelegeator.store(result,m);
  }
  return result;
}

Fixed version (ground truth):
protected List<Object> populateEntities(EntityMetadata m,Client client){
  log.debug("String_Node_Str");
  List<Object> result=null;
  ((RDBMSEntityReader)getReader()).setConditions(getKunderaQuery().getFilterClauseQueue());
  ((RDBMSEntityReader)getReader()).setFilter(getKunderaQuery().getFilter());
  try {
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      List<String> relations=new ArrayList<String>();
      List r=((HibernateClient)client).find(((RDBMSEntityReader)getReader()).getSqlQueryFromJPA(m,relations,null),relations,m);
      result=new ArrayList<Object>(r.size());
      for (      Object o : r) {
        Class clazz=m.getEntityClazz();
        if (!o.getClass().isAssignableFrom(m.getEntityClazz())) {
          o=((Object[])o)[0];
        }
        result.add(o);
      }
    }
 else {
      result=populateUsingLucene(m,client,result);
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
  if (result != null && !result.isEmpty()) {
    persistenceDelegeator.store(result,m);
  }
  return result;
}
Program: 176996
Project: 176996
Buggy source:
/** 
 * Prepare document.
 * @param metadata the metadata
 * @param object the object
 * @param embeddedColumnName the super column name
 * @return the document
 */
protected Document prepareDocumentForSuperColumn(EntityMetadata metadata,Object object,String embeddedColumnName,String parentId,Class<?> clazz){
  Document currentDoc;
  currentDoc=new Document();
  addEntityClassToDocument(metadata,object,currentDoc);
  addSuperColumnNameToDocument(embeddedColumnName,currentDoc);
  return currentDoc;
}

Fixed version (ground truth):
/** 
 * Prepare document.
 * @param metadata the metadata
 * @param object the object
 * @param embeddedColumnName the super column name
 * @return the document
 */
protected Document prepareDocumentForSuperColumn(EntityMetadata metadata,Object object,String embeddedColumnName,String parentId,Class<?> clazz){
  Document currentDoc;
  currentDoc=new Document();
  addEntityClassToDocument(metadata,object,currentDoc);
  addSuperColumnNameToDocument(embeddedColumnName,currentDoc);
  indexParentKey(parentId,currentDoc,clazz);
  return currentDoc;
}
Program: 176999
Project: 176999
Buggy source:
/** 
 * Returns lucene based query.
 * @param clazzFieldName lucene field name for class
 * @param clazzName class name
 * @param idFieldName lucene id field name
 * @param idFieldValue lucene id field value
 * @return query lucene query.
 */
protected static String getQuery(String clazzFieldName,String clazzName,String idFieldName,String idFieldValue){
  StringBuffer sb=new StringBuffer("String_Node_Str");
  sb.append(clazzFieldName);
  sb.append("String_Node_Str");
  sb.append(clazzName);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(idFieldName);
  sb.append("String_Node_Str");
  sb.append(idFieldValue);
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Returns lucene based query.
 * @param clazzFieldName lucene field name for class
 * @param clazzName class name
 * @param idFieldName lucene id field name
 * @param idFieldValue lucene id field value
 * @return query lucene query.
 */
protected static String getQuery(String clazzFieldName,String clazzName,String idFieldName,String idFieldValue,String entityClazz){
  StringBuffer sb=new StringBuffer("String_Node_Str");
  sb.append(clazzFieldName);
  sb.append("String_Node_Str");
  sb.append(clazzName);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(idFieldName);
  sb.append("String_Node_Str");
  sb.append(idFieldValue);
  if (entityClazz != null) {
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
    sb.append(DocumentIndexer.ENTITY_CLASS_FIELD);
    sb.append("String_Node_Str");
    sb.append(entityClazz);
  }
  return sb.toString();
}
Program: 177000
Project: 177000
Buggy source:
/** 
 * Removed association entit(ies) from the enclosing entity
 * @param entity
 * @param associationEntity
 * @param field
 * @param setNull
 */
protected void onDetach(Object entity,Object associationEntity,Field field,boolean setNull){
  try {
    if (entity != null) {
      if (entity instanceof Collection<?>) {
        Collection<?> entityCollection=(Collection<?>)entity;
        for (        Object entityObj : entityCollection) {
          PropertyAccessorHelper.set(entityObj,field,setNull || entity == null ? null : Set.class.isAssignableFrom(field.getType()) ? null : associationEntity.getClass().newInstance());
        }
      }
 else {
        PropertyAccessorHelper.set(entity,field,setNull || associationEntity == null ? null : associationEntity.getClass().newInstance());
      }
    }
  }
 catch (  PropertyAccessException e) {
    e.printStackTrace();
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Removed association entit(ies) from the enclosing entity
 * @param entity
 * @param associationEntity
 * @param field
 * @param setNull
 */
protected void onDetach(Object entity,Object associationEntity,Field field,boolean setNull){
  try {
    if (entity != null) {
      if (entity instanceof Collection<?>) {
        Collection<?> entityCollection=(Collection<?>)entity;
        for (        Object entityObj : entityCollection) {
          PropertyAccessorHelper.set(entityObj,field,setNull || entity == null ? null : Collection.class.isAssignableFrom(field.getType()) ? null : associationEntity.getClass().newInstance());
        }
      }
 else {
        PropertyAccessorHelper.set(entity,field,setNull || associationEntity == null ? null : associationEntity.getClass().newInstance());
      }
    }
  }
 catch (  PropertyAccessException e) {
    e.printStackTrace();
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
}
Program: 177002
Project: 177002
Buggy source:
/** 
 * Save graph.
 * @param objectGraph the object graph
 * @throws Exception the exception
 */
private void removeGraph(EntitySaveGraph objectGraph) throws Exception {
  EntityMetadata metadata=getMetadata(objectGraph.getParentClass());
  Object parentEntity=objectGraph.getParentEntity();
  List<EntitySaveGraph> relationGraphs=null;
  if (objectGraph.isIsswapped() && !metadata.getRelations().isEmpty() && !objectGraph.getChildClass().equals(objectGraph.getParentClass())) {
    relationGraphs=getGraph(parentEntity,metadata);
    List<EntitySaveGraph> uniqueGraphs=getDisjointGraph(objectGraph,relationGraphs);
    for (    EntitySaveGraph g : uniqueGraphs) {
      removeGraph(g);
    }
  }
  if (parentEntity != null) {
    objectGraph.setParentId(getId(parentEntity,metadata));
    Client pClient=getClient(metadata);
    pClient.delete(parentEntity,objectGraph.getParentId(),metadata);
  }
  Object childEntity=objectGraph.getChildEntity();
  if (objectGraph.getParentEntity() != null && childEntity != null) {
    onClientHandle(objectGraph,childEntity);
  }
  session.remove(parentEntity.getClass(),objectGraph.getParentEntity());
}

Fixed version (ground truth):
/** 
 * Save graph.
 * @param objectGraph the object graph
 * @throws Exception the exception
 */
private void removeGraph(EntitySaveGraph objectGraph) throws Exception {
  EntityMetadata metadata=getMetadata(objectGraph.getParentClass());
  Object parentEntity=objectGraph.getParentEntity();
  List<EntitySaveGraph> relationGraphs=null;
  if (objectGraph.isIsswapped() && !metadata.getRelations().isEmpty() && parentEntity != null && !objectGraph.getChildClass().equals(objectGraph.getParentClass())) {
    relationGraphs=getGraph(parentEntity,metadata);
    List<EntitySaveGraph> uniqueGraphs=getDisjointGraph(objectGraph,relationGraphs);
    for (    EntitySaveGraph g : uniqueGraphs) {
      removeGraph(g);
    }
  }
  if (parentEntity != null) {
    objectGraph.setParentId(getId(parentEntity,metadata));
    Client pClient=getClient(metadata);
    pClient.delete(parentEntity,objectGraph.getParentId(),metadata);
    session.remove(parentEntity.getClass(),objectGraph.getParentEntity());
  }
  Object childEntity=objectGraph.getChildEntity();
  if (childEntity != null) {
    onClientHandle(objectGraph,childEntity);
  }
}
Program: 177003
Project: 177003
Buggy source:
/** 
 * On client persist.
 * @param objectGraph the object graph
 * @param childEntity the child entity
 * @throws Exception the exception
 */
private void onClientHandle(EntitySaveGraph objectGraph,Object childEntity) throws Exception {
  if (childEntity instanceof Collection<?>) {
    Collection<?> childCol=(Collection<?>)childEntity;
    for (    Object ch : childCol) {
      onClientDelete(ch,objectGraph);
    }
  }
 else {
    onClientDelete(childEntity,objectGraph);
  }
}

Fixed version (ground truth):
/** 
 * On client persist.
 * @param objectGraph the object graph
 * @param childEntity the child entity
 * @throws Exception the exception
 */
private void onClientHandle(EntitySaveGraph objectGraph,Object childEntity) throws Exception {
  if (childEntity instanceof Collection<?>) {
    Collection<?> childCol=(Collection<?>)childEntity;
    for (    Object ch : childCol) {
      if (ch != null) {
        onClientDelete(ch,objectGraph);
      }
    }
  }
 else {
    if (childEntity != null) {
      onClientDelete(childEntity,objectGraph);
    }
  }
}
Program: 177004
Project: 177004
Buggy source:
/** 
 * Populate using lucene.
 * @param m the m
 * @param client the client
 * @param result the result
 * @return the list
 */
protected List<Object> populateUsingLucene(EntityMetadata m,Client client,List<Object> result){
  String luceneQ=getLuceneQueryFromJPAQuery();
  Map<String,String> searchFilter=client.getIndexManager().search(luceneQ,Constants.INVALID,Constants.INVALID);
  if (kunderaQuery.isAliasOnly()) {
    String[] primaryKeys=searchFilter.values().toArray(new String[]{});
    try {
      result=(List<Object>)client.findAll(m.getEntityClazz(),primaryKeys);
    }
 catch (    Exception e) {
    }
  }
 else {
    return (List<Object>)persistenceDelegeator.find(m.getEntityClazz(),searchFilter);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Populate using lucene.
 * @param m the m
 * @param client the client
 * @param result the result
 * @return the list
 */
protected List<Object> populateUsingLucene(EntityMetadata m,Client client,List<Object> result){
  String luceneQ=getLuceneQueryFromJPAQuery();
  Map<String,String> searchFilter=client.getIndexManager().search(luceneQ,Constants.INVALID,Constants.INVALID);
  if (kunderaQuery.isAliasOnly()) {
    String[] primaryKeys=searchFilter.values().toArray(new String[]{});
    Set<String> uniquePKs=new HashSet<String>(Arrays.asList(primaryKeys));
    try {
      result=(List<Object>)persistenceDelegeator.find(m.getEntityClazz(),uniquePKs.toArray());
    }
 catch (    Exception e) {
    }
  }
 else {
    return (List<Object>)persistenceDelegeator.find(m.getEntityClazz(),searchFilter);
  }
  return result;
}
Program: 177005
Project: 177005
Buggy source:
/** 
 * Gets the session instance.
 * @return the session instance
 */
private Session getSessionInstance(){
  Session s=null;
  if (sf.isClosed()) {
    s=sf.openSession();
  }
 else {
    s=sf.getCurrentSession();
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Gets the session instance.
 * @return the session instance
 */
private Session getSessionInstance(){
  Session s=null;
  if (sf.isClosed()) {
    s=sf.openSession();
  }
 else {
    s=sf.getCurrentSession();
    if (s.isOpen()) {
      s=sf.openSession();
    }
  }
  return s;
}
Program: 177006
Project: 177006
Buggy source:
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  if (relationNames != null && !relationNames.isEmpty()) {
    Set<String> keys=new HashSet<String>(1);
    keys.add(primaryKey.toString());
    String query=getSqlQueryFromJPA(m,relationNames,keys);
    return populateEnhanceEntities(m,relationNames,client,query).get(0);
  }
 else {
    Object o;
    try {
      o=client.find(m.getEntityClazz(),primaryKey,null);
    }
 catch (    Exception e) {
      throw new PersistenceException(e.getMessage());
    }
    return o != null ? new EnhanceEntity(o,getId(o,m),null) : null;
  }
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  if (relationNames != null && !relationNames.isEmpty()) {
    Set<String> keys=new HashSet<String>(1);
    keys.add(primaryKey.toString());
    String query=getSqlQueryFromJPA(m,relationNames,keys);
    List<EnhanceEntity> results=populateEnhanceEntities(m,relationNames,client,query);
    return results != null && !results.isEmpty() ? results.get(0) : null;
  }
 else {
    Object o;
    try {
      o=client.find(m.getEntityClazz(),primaryKey,null);
    }
 catch (    Exception e) {
      throw new PersistenceException(e.getMessage());
    }
    return o != null ? new EnhanceEntity(o,getId(o,m),null) : null;
  }
}
Program: 177007
Project: 177007
Buggy source:
/** 
 * Populate enhance entities.
 * @param m the m
 * @param relationNames the relation names
 * @param client the client
 * @param sqlQuery the sql query
 * @return the list
 */
private List<EnhanceEntity> populateEnhanceEntities(EntityMetadata m,List<String> relationNames,Client client,String sqlQuery){
  List<EnhanceEntity> ls=null;
  List result=((HibernateClient)client).find(sqlQuery,relationNames,m.getEntityClazz());
  if (!result.isEmpty()) {
    ls=new ArrayList<EnhanceEntity>(result.size());
    for (    Object o : result) {
      Class clazz=m.getEntityClazz();
      if (!o.getClass().isAssignableFrom(m.getEntityClazz())) {
        o=((Object[])o)[0];
      }
      EnhanceEntity e=new EnhanceEntity(o,getId(o,m),populateRelations(relationNames,o));
      ls.add(e);
    }
  }
  return ls;
}

Fixed version (ground truth):
/** 
 * Populate enhance entities.
 * @param m the m
 * @param relationNames the relation names
 * @param client the client
 * @param sqlQuery the sql query
 * @return the list
 */
private List<EnhanceEntity> populateEnhanceEntities(EntityMetadata m,List<String> relationNames,Client client,String sqlQuery){
  List<EnhanceEntity> ls=null;
  List result=((HibernateClient)client).find(sqlQuery,relationNames,m.getEntityClazz());
  try {
    if (!result.isEmpty()) {
      ls=new ArrayList<EnhanceEntity>(result.size());
      for (      Object o : result) {
        Class clazz=m.getEntityClazz();
        Object entity=clazz.newInstance();
        if (!o.getClass().isAssignableFrom(clazz)) {
          entity=((Object[])o)[0];
        }
        EnhanceEntity e=new EnhanceEntity(entity,getId(entity,m),populateRelations(relationNames,(Object[])o));
        ls.add(e);
      }
    }
  }
 catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
  return ls;
}
Program: 177008
Project: 177008
Buggy source:
/** 
 * Populate relations.
 * @param relations the relations
 * @param o the o
 * @return the map
 */
private Map<String,Object> populateRelations(List<String> relations,Object... o){
  Map<String,Object> relationVal=new HashMap<String,Object>(relations.size());
  int counter=1;
  for (  String r : relations) {
    relationVal.put(r,o[counter++]);
  }
  return relationVal;
}

Fixed version (ground truth):
/** 
 * Populate relations.
 * @param relations the relations
 * @param o the o
 * @return the map
 */
private Map<String,Object> populateRelations(List<String> relations,Object[] o){
  Map<String,Object> relationVal=new HashMap<String,Object>(relations.size());
  int counter=1;
  for (  String r : relations) {
    relationVal.put(r,o[counter++]);
  }
  return relationVal;
}
Program: 177009
Project: 177009
Buggy source:
@Override public List<EnhanceEntity> populateRelation(EntityMetadata m,List<String> relationNames,boolean isParent,Client client){
  List<EnhanceEntity> ls=null;
  if (!isParent) {
    String sqlQuery=null;
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      sqlQuery=getSqlQueryFromJPA(m,relationNames,null);
    }
 else {
      Set<String> rSet=fetchDataFromLucene(client);
      sqlQuery=getSqlQueryFromJPA(m,relationNames,rSet);
    }
    ls=populateEnhanceEntities(m,relationNames,client,sqlQuery);
  }
 else {
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      try {
        List entities=((HibernateClient)client).find(jpaQuery,new ArrayList<String>(),m.getEntityClazz());
        ls=new ArrayList<EnhanceEntity>(entities.size());
        transform(m,ls,entities);
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + e.getMessage());
        throw new QueryHandlerException(e.getMessage());
      }
    }
 else {
      onAssociationUsingLucene(m,client,ls);
    }
  }
  return ls;
}

Fixed version (ground truth):
@Override public List<EnhanceEntity> populateRelation(EntityMetadata m,List<String> relationNames,boolean isParent,Client client){
  List<EnhanceEntity> ls=null;
  if (!isParent) {
    String sqlQuery=null;
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      sqlQuery=getSqlQueryFromJPA(m,relationNames,null);
    }
 else {
      Set<String> rSet=fetchDataFromLucene(client);
      if (rSet != null && !rSet.isEmpty()) {
        filter="String_Node_Str";
      }
      sqlQuery=getSqlQueryFromJPA(m,relationNames,rSet);
    }
    ls=populateEnhanceEntities(m,relationNames,client,sqlQuery);
  }
 else {
    if (MetadataUtils.useSecondryIndex(client.getPersistenceUnit())) {
      try {
        List entities=((HibernateClient)client).find(jpaQuery,new ArrayList<String>(),m.getEntityClazz());
        ls=new ArrayList<EnhanceEntity>(entities.size());
        transform(m,ls,entities);
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + e.getMessage());
        throw new QueryHandlerException(e.getMessage());
      }
    }
 else {
      onAssociationUsingLucene(m,client,ls);
    }
  }
  return ls;
}
Program: 177010
Project: 177010
Buggy source:
@Override public EnhanceEntity findById(String primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),primaryKey,relationNames);
    return new EnhanceEntity(o,getId(o,m),null);
  }
 catch (  Exception e) {
    throw new PersistenceException("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(String primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),primaryKey,relationNames);
    return (EnhanceEntity)o;
  }
 catch (  Exception e) {
    throw new PersistenceException("String_Node_Str" + e.getMessage());
  }
}
Program: 177012
Project: 177012
Buggy source:
/** 
 * @param entityMetadata
 * @param id
 * @throws Exception
 * @throws PropertyAccessException
 */
private void onPersist(EntityMetadata entityMetadata,Object entity,String id,List<RelationHolder> relations) throws Exception, PropertyAccessException {
  String dbName=entityMetadata.getSchema();
  String documentName=entityMetadata.getTableName();
  log.debug("String_Node_Str" + dbName + "String_Node_Str"+ documentName+ "String_Node_Str"+ id);
  DBCollection dbCollection=mongoDb.getCollection(documentName);
  BasicDBObject document=new MongoDBDataHandler(this,getPersistenceUnit()).getDocumentFromEntity(entityMetadata,entity,relations);
  dbCollection.insert(document);
}

Fixed version (ground truth):
/** 
 * @param entityMetadata
 * @param id
 * @throws Exception
 * @throws PropertyAccessException
 */
private void onPersist(EntityMetadata entityMetadata,Object entity,String id,List<RelationHolder> relations) throws Exception, PropertyAccessException {
  String dbName=entityMetadata.getSchema();
  String documentName=entityMetadata.getTableName();
  log.debug("String_Node_Str" + dbName + "String_Node_Str"+ documentName+ "String_Node_Str"+ id);
  DBCollection dbCollection=mongoDb.getCollection(documentName);
  BasicDBObject document=new MongoDBDataHandler(this,getPersistenceUnit()).getDocumentFromEntity(entityMetadata,entity,relations);
  dbCollection.save(document);
}
Program: 177013
Project: 177013
Buggy source:
/** 
 * Removes the.
 * @param e the e
 */
public void remove(Object e){
  try {
    EntityMetadata metadata=getMetadata(e.getClass());
    getEventDispatcher().fireEventListeners(metadata,e,PreRemove.class);
    EntityInterceptor interceptor=new EntityInterceptor();
    List<EntitySaveGraph> objectGraphs=interceptor.handleRelation(e,metadata);
    for (    EntitySaveGraph objectGraph : objectGraphs) {
      removeGraph(objectGraph);
    }
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
    log.debug("String_Node_Str" + e.getClass());
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
}

Fixed version (ground truth):
/** 
 * Removes the.
 * @param e the e
 */
public void remove(Object e){
  try {
    EntityMetadata metadata=getMetadata(e.getClass());
    getEventDispatcher().fireEventListeners(metadata,e,PreRemove.class);
    EntityInterceptor interceptor=new EntityInterceptor();
    List<EntitySaveGraph> objectGraphs=interceptor.handleRelation(e,metadata);
    for (    EntitySaveGraph objectGraph : objectGraphs) {
      removeGraph(objectGraph);
    }
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
    logger.debug("String_Node_Str" + e.getClass());
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
}
Program: 177015
Project: 177015
Buggy source:
/** 
 * Merge.
 * @param < E > the element type
 * @param e the e
 * @return the e
 */
public <E>E merge(E e){
  try {
    List<EnhancedEntity> reachableEntities=EntityResolver.resolve(e,CascadeType.MERGE,getPersistenceUnits());
    for (    EnhancedEntity o : reachableEntities) {
      log.debug("String_Node_Str" + o);
      EntityMetadata m=KunderaMetadataManager.getEntityMetadata(o.getEntity().getClass(),getPersistenceUnits());
      getEventDispatcher().fireEventListeners(m,o,PreUpdate.class);
      persist(o.getEntity());
      getEventDispatcher().fireEventListeners(m,o,PostUpdate.class);
    }
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
  return e;
}

Fixed version (ground truth):
/** 
 * Merge.
 * @param < E > the element type
 * @param e the e
 * @return the e
 */
public <E>E merge(E e){
  try {
    List<EnhancedEntity> reachableEntities=EntityResolver.resolve(e,CascadeType.MERGE,getPersistenceUnits());
    for (    EnhancedEntity o : reachableEntities) {
      logger.debug("String_Node_Str" + o);
      EntityMetadata m=KunderaMetadataManager.getEntityMetadata(o.getEntity().getClass(),getPersistenceUnits());
      getEventDispatcher().fireEventListeners(m,o,PreUpdate.class);
      persist(o.getEntity());
      getEventDispatcher().fireEventListeners(m,o,PostUpdate.class);
    }
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
  return e;
}
Program: 177016
Project: 177016
Buggy source:
/** 
 * Persist.
 * @param e the e
 */
public void persist(Object e){
  try {
    EntityMetadata metadata=getMetadata(e.getClass());
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
    List<EntitySaveGraph> objectGraphs=getGraph(e,metadata);
    for (    EntitySaveGraph objectGraph : objectGraphs) {
      saveGraph(objectGraph);
    }
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
    log.debug("String_Node_Str" + e.getClass());
  }
 catch (  Exception exp) {
    exp.printStackTrace();
    throw new PersistenceException(exp);
  }
}

Fixed version (ground truth):
/** 
 * Persist.
 * @param e the e
 */
public void persist(Object e){
  try {
    EntityMetadata metadata=getMetadata(e.getClass());
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
    List<EntitySaveGraph> objectGraphs=getGraph(e,metadata);
    for (    EntitySaveGraph objectGraph : objectGraphs) {
      saveGraph(objectGraph);
    }
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
    logger.debug("String_Node_Str" + e.getClass());
  }
 catch (  Exception exp) {
    exp.printStackTrace();
    throw new PersistenceException(exp);
  }
}
Program: 177017
Project: 177017
Buggy source:
/** 
 * Persist one child entity into persistence store. Also checks whether this child entity has further relationships. If yes, it generates a graph for them and saves them recursively up to "n" level.
 * @param child the child Entity Object.
 * @param objectGraph the object graph to which this child entity belongs.
 */
private void persistOneChildEntity(Object child,EntitySaveGraph objectGraph){
  if (getSession().lookup(child.getClass(),objectGraph.getChildId()) == null) {
    EntityMetadata metadata=getMetadata(objectGraph.getChildClass());
    boolean imChildProcessed=false;
    List<Relation> relations=metadata.getRelations();
    List<EntitySaveGraph> objectGraphs=getGraph(child,metadata);
    if (!((relations == null || relations.isEmpty()) || objectGraph.isIsswapped())) {
      for (      EntitySaveGraph graph : objectGraphs) {
        if (!graph.equals(objectGraph)) {
          graph.setRevFKeyName(objectGraph.getfKeyName());
          graph.setRevFKeyValue(objectGraph.getParentId());
          graph.setRevParentClass(objectGraph.getParentClass());
          imChildProcessed=true;
          saveGraph(graph);
        }
      }
    }
    if (!imChildProcessed) {
      saveImmediateChild(child,objectGraph,metadata);
    }
  }
}

Fixed version (ground truth):
/** 
 * Persist one child entity into persistence store. Also checks whether this child entity has further relationships. If yes, it generates a graph for them and saves them recursively up to "n" level.
 * @param child the child Entity Object.
 * @param objectGraph the object graph to which this child entity belongs.
 */
private void persistOneChildEntity(Object child,EntitySaveGraph objectGraph){
  EntityMetadata metadata=getMetadata(objectGraph.getChildClass());
  String childId=null;
  try {
    childId=PropertyAccessorHelper.getId(child,metadata);
  }
 catch (  PropertyAccessException e) {
    logger.error("String_Node_Str" + child + "String_Node_Str");
    return;
  }
  if (getSession().lookup(child.getClass(),childId) == null) {
    boolean imChildProcessed=false;
    List<Relation> relations=metadata.getRelations();
    List<EntitySaveGraph> objectGraphs=getGraph(child,metadata);
    if (!((relations == null || relations.isEmpty()) || objectGraph.isIsswapped())) {
      for (      EntitySaveGraph graph : objectGraphs) {
        if (!graph.equals(objectGraph)) {
          graph.setRevFKeyName(objectGraph.getfKeyName());
          graph.setRevFKeyValue(objectGraph.getParentId());
          graph.setRevParentClass(objectGraph.getParentClass());
          imChildProcessed=true;
          saveGraph(graph);
        }
      }
    }
    if (!imChildProcessed) {
      saveImmediateChild(child,objectGraph,metadata);
    }
  }
}
Program: 177018
Project: 177018
Buggy source:
/** 
 * Gets the string.
 * @param from the from
 * @param field the field
 * @return the string
 * @throws PropertyAccessException the property access exception
 */
public static String getString(Object from,Field field) throws PropertyAccessException {
  PropertyAccessor<?> accessor=PropertyAccessorFactory.getPropertyAccessor(field);
  Object object=getObject(from,field);
  return object != null ? accessor.toString() : null;
}

Fixed version (ground truth):
/** 
 * Gets the string.
 * @param from the from
 * @param field the field
 * @return the string
 * @throws PropertyAccessException the property access exception
 */
public static String getString(Object from,Field field) throws PropertyAccessException {
  PropertyAccessor<?> accessor=PropertyAccessorFactory.getPropertyAccessor(field);
  Object object=getObject(from,field);
  return object != null ? accessor.toString(object) : null;
}
Program: 177019
Project: 177019
Buggy source:
/** 
 * Prepare document.
 * @param metadata the metadata
 * @param object the object
 * @param embeddedColumnName the super column name
 * @return the document
 */
protected Document prepareDocumentForSuperColumn(EntityMetadata metadata,Object object,String embeddedColumnName,String parentId,Class<?> clazz){
  Document currentDoc;
  currentDoc=new Document();
  addEntityClassToDocument(metadata,object,currentDoc);
  addSuperColumnNameToDocument(embeddedColumnName,currentDoc);
  indexParentKey(parentId,currentDoc,clazz);
  return currentDoc;
}

Fixed version (ground truth):
/** 
 * Prepare document.
 * @param metadata the metadata
 * @param object the object
 * @param embeddedColumnName the super column name
 * @return the document
 */
protected Document prepareDocumentForSuperColumn(EntityMetadata metadata,Object object,String embeddedColumnName,String parentId,Class<?> clazz){
  Document currentDoc;
  currentDoc=new Document();
  addEntityClassToDocument(metadata,object,currentDoc);
  addSuperColumnNameToDocument(embeddedColumnName,currentDoc);
  return currentDoc;
}
Program: 177021
Project: 177021
Buggy source:
/** 
 * Fetches data held in Thrift row columns and populates to Entity objects
 * @param < E > the element type
 * @param em the em
 * @param clazz the clazz
 * @param m the m
 * @param thriftRow the cr
 * @return the e
 * @throws Exception the exception
 */
public Object fromColumnThriftRow(Class<?> clazz,EntityMetadata m,ThriftRow thriftRow,List<String> relationNames,boolean isWrapperReq) throws Exception {
  Object entity=clazz.newInstance();
  Map<String,Object> relations=new HashMap<String,Object>();
  PropertyAccessorHelper.setId(entity,m,thriftRow.getId());
  for (  Column c : thriftRow.getColumns()) {
    String thriftColumnName=PropertyAccessorFactory.STRING.fromBytes(c.getName());
    byte[] thriftColumnValue=c.getValue();
    if (null == thriftColumnValue) {
      continue;
    }
    com.impetus.kundera.metadata.model.Column column=m.getColumn(thriftColumnName);
    if (column != null) {
      try {
        PropertyAccessorHelper.set(entity,column.getField(),thriftColumnValue);
      }
 catch (      PropertyAccessException pae) {
        log.warn(pae.getMessage());
      }
    }
 else {
      if (relationNames != null && !relationNames.isEmpty() && relationNames.contains(thriftColumnName)) {
        String value=PropertyAccessorFactory.STRING.fromBytes(thriftColumnValue);
        relations.put(thriftColumnName,value);
      }
    }
  }
  return isWrapperReq ? new EnhanceEntity(entity,thriftRow.getId(),relations) : entity;
}

Fixed version (ground truth):
/** 
 * Fetches data held in Thrift row columns and populates to Entity objects
 * @param < E > the element type
 * @param em the em
 * @param clazz the clazz
 * @param m the m
 * @param thriftRow the cr
 * @return the e
 * @throws Exception the exception
 */
public Object fromColumnThriftRow(Class<?> clazz,EntityMetadata m,ThriftRow thriftRow,List<String> relationNames,boolean isWrapperReq) throws Exception {
  Object entity=null;
  Map<String,Object> relations=new HashMap<String,Object>();
  for (  Column c : thriftRow.getColumns()) {
    if (entity == null) {
      entity=clazz.newInstance();
      PropertyAccessorHelper.setId(entity,m,thriftRow.getId());
    }
    String thriftColumnName=PropertyAccessorFactory.STRING.fromBytes(c.getName());
    byte[] thriftColumnValue=c.getValue();
    if (null == thriftColumnValue) {
      continue;
    }
    com.impetus.kundera.metadata.model.Column column=m.getColumn(thriftColumnName);
    if (column != null) {
      try {
        PropertyAccessorHelper.set(entity,column.getField(),thriftColumnValue);
      }
 catch (      PropertyAccessException pae) {
        log.warn(pae.getMessage());
      }
    }
 else {
      if (relationNames != null && !relationNames.isEmpty() && relationNames.contains(thriftColumnName)) {
        String value=PropertyAccessorFactory.STRING.fromBytes(thriftColumnValue);
        relations.put(thriftColumnName,value);
      }
    }
  }
  return isWrapperReq ? new EnhanceEntity(entity,thriftRow.getId(),relations) : entity;
}
Program: 177023
Project: 177023
Buggy source:
/** 
 * Method responsible for reading bacl entity and relations using secondary indexes(if it holds any relation), else retrieve row keys using lucene.
 * @param m entity meta data
 * @param relationNames relation names
 * @param isParent if entity is not holding any relation.
 * @param client client instance
 * @return list of wrapped enhance entities.
 */
@Override public List<EnhanceEntity> populateRelation(EntityMetadata m,List<String> relationNames,boolean isParent,Client client){
  List<EnhanceEntity> ls=null;
  if (!isParent) {
    if (MetadataUtils.useSecondryIndex(m.getPersistenceUnit())) {
      ls=((PelopsClient)client).find(m,relationNames,this.conditions);
    }
 else {
      Set<String> rSet=fetchDataFromLucene(client);
      try {
        ls=(List<EnhanceEntity>)((PelopsClient)client).find(m.getEntityClazz(),relationNames,true,m,rSet.toArray(new String[]{}));
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + e.getMessage());
        throw new QueryHandlerException(e.getMessage());
      }
    }
  }
 else {
    if (MetadataUtils.useSecondryIndex(m.getPersistenceUnit())) {
      ls=((PelopsClient)client).find(this.conditions,m,true,null);
    }
 else {
      onAssociationUsingLucene(m,client,ls);
    }
  }
  return ls;
}

Fixed version (ground truth):
/** 
 * Method responsible for reading bacl entity and relations using secondary indexes(if it holds any relation), else retrieve row keys using lucene.
 * @param m entity meta data
 * @param relationNames relation names
 * @param isParent if entity is not holding any relation.
 * @param client client instance
 * @return list of wrapped enhance entities.
 */
@Override public List<EnhanceEntity> populateRelation(EntityMetadata m,List<String> relationNames,boolean isParent,Client client){
  List<EnhanceEntity> ls=null;
  if (!isParent) {
    if (MetadataUtils.useSecondryIndex(m.getPersistenceUnit())) {
      ls=((PelopsClient)client).find(m,relationNames,this.conditions);
    }
 else {
      Set<String> rSet=fetchDataFromLucene(client);
      try {
        ls=(List<EnhanceEntity>)((PelopsClient)client).find(m.getEntityClazz(),relationNames,true,m,rSet.toArray(new String[]{}));
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + e.getMessage());
        throw new QueryHandlerException(e.getMessage());
      }
    }
  }
 else {
    if (MetadataUtils.useSecondryIndex(m.getPersistenceUnit())) {
      ls=((PelopsClient)client).find(this.conditions,m,true,null);
    }
 else {
      ls=onAssociationUsingLucene(m,client,ls);
    }
  }
  return ls;
}
Program: 177025
Project: 177025
Buggy source:
protected void transform(EntityMetadata m,List<EnhanceEntity> ls,List resultList){
  for (  Object r : resultList) {
    EnhanceEntity e=new EnhanceEntity(r,getId(r,m),null);
    ls.add(e);
  }
}

Fixed version (ground truth):
protected List<EnhanceEntity> transform(EntityMetadata m,List<EnhanceEntity> ls,List resultList){
  if ((ls == null || ls.isEmpty()) && resultList != null && !resultList.isEmpty()) {
    ls=new ArrayList<EnhanceEntity>(resultList.size());
  }
  for (  Object r : resultList) {
    EnhanceEntity e=new EnhanceEntity(r,getId(r,m),null);
    ls.add(e);
  }
  return ls;
}
Program: 177026
Project: 177026
Buggy source:
protected void onAssociationUsingLucene(EntityMetadata m,Client client,List<EnhanceEntity> ls){
  Set<String> rSet=fetchDataFromLucene(client);
  try {
    List resultList=client.find(m.getEntityClazz(),rSet.toArray(new String[]{}));
    transform(m,ls,resultList);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
}

Fixed version (ground truth):
protected List<EnhanceEntity> onAssociationUsingLucene(EntityMetadata m,Client client,List<EnhanceEntity> ls){
  Set<String> rSet=fetchDataFromLucene(client);
  try {
    List resultList=client.find(m.getEntityClazz(),rSet.toArray(new String[]{}));
    return transform(m,ls,resultList);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
}
Program: 177028
Project: 177028
Buggy source:
/** 
 * Gets the reader.
 * @param client the client
 * @return the reader
 */
private EntityReader getReader(Client client){
  return client.getReader();
}

Fixed version (ground truth):
/** 
 * Gets the reader.
 * @param client the client
 * @return the reader
 */
public EntityReader getReader(Client client){
  return client.getReader();
}
Program: 177029
Project: 177029
Buggy source:
/** 
 * Handle client.
 * @param child the child
 * @param objectGraph the object graph
 * @throws Exception the exception
 */
private void onClientDelete(Object child,EntitySaveGraph objectGraph) throws Exception {
  EntityMetadata metadata=getMetadata(objectGraph.getChildClass());
  String id=getId(child,metadata);
  objectGraph.setChildId(id);
  Client chClient=getClient(metadata);
  chClient.delete(child,id,metadata);
}

Fixed version (ground truth):
/** 
 * Handle client.
 * @param child the child
 * @param objectGraph the object graph
 * @throws Exception the exception
 */
private void onClientDelete(Object child,EntitySaveGraph objectGraph) throws Exception {
  EntityMetadata metadata=getMetadata(objectGraph.getChildClass());
  List<Relation> relations=metadata.getRelations();
  boolean imChildProcessed=false;
  List<EntitySaveGraph> objectGraphs=getGraph(child,metadata);
  if (!((relations == null || relations.isEmpty()) || objectGraph.isIsswapped())) {
    for (    EntitySaveGraph graph : objectGraphs) {
      if (!graph.equals(objectGraph)) {
        graph.setRevFKeyName(objectGraph.getfKeyName());
        graph.setRevFKeyValue(objectGraph.getParentId());
        graph.setRevParentClass(objectGraph.getParentClass());
        imChildProcessed=true;
        removeGraph(graph);
      }
    }
  }
  if (!imChildProcessed) {
    String id=getId(child,metadata);
    objectGraph.setChildId(id);
    Client chClient=getClient(metadata);
    chClient.delete(child,id,metadata);
  }
}
Program: 177031
Project: 177031
Buggy source:
@Override protected List<Object> populateEntities(EntityMetadata m,Client client){
  log.debug("String_Node_Str");
  List<Object> result=null;
  if (MetadataUtils.useSecondryIndex(m.getPersistenceUnit())) {
    List<IndexClause> ixClause=prepareIndexClause();
    result=((PelopsClient)client).find(ixClause,m,false,null);
  }
 else {
    result=populateUsingLucene(m,client,result);
  }
  return result;
}

Fixed version (ground truth):
@Override protected List<Object> populateEntities(EntityMetadata m,Client client){
  log.debug("String_Node_Str");
  List<Object> result=null;
  if (MetadataUtils.useSecondryIndex(m.getPersistenceUnit())) {
    List<IndexClause> ixClause=prepareIndexClause(m);
    result=((PelopsClient)client).find(ixClause,m,false,null);
  }
 else {
    result=populateUsingLucene(m,client,result);
  }
  return result;
}
Program: 177032
Project: 177032
Buggy source:
private List<IndexClause> prepareIndexClause(){
  List<IndexClause> clauses=new ArrayList<IndexClause>();
  List<IndexExpression> expr=new ArrayList<IndexExpression>();
  for (  Object o : getKunderaQuery().getFilterClauseQueue()) {
    if (o instanceof FilterClause) {
      FilterClause clause=((FilterClause)o);
      String fieldName=getColumnName(clause.getProperty());
      String condition=clause.getCondition();
      String value=clause.getValue();
      IndexClause indexClause=Selector.newIndexClause(fieldName,Integer.SIZE);
      expr.add(Selector.newIndexExpression(fieldName,getOperator(condition),Bytes.fromByteArray(value.getBytes())));
      indexClause.setExpressions(expr);
      clauses.add(indexClause);
    }
  }
  return clauses;
}

Fixed version (ground truth):
private List<IndexClause> prepareIndexClause(EntityMetadata m){
  IndexClause indexClause=Selector.newIndexClause(Bytes.EMPTY,Integer.SIZE);
  List<IndexClause> clauses=new ArrayList<IndexClause>();
  List<IndexExpression> expr=new ArrayList<IndexExpression>();
  for (  Object o : getKunderaQuery().getFilterClauseQueue()) {
    if (o instanceof FilterClause) {
      FilterClause clause=((FilterClause)o);
      String fieldName=getColumnName(clause.getProperty());
      String condition=clause.getCondition();
      String value=clause.getValue();
      expr.add(Selector.newIndexExpression(fieldName,getOperator(condition),getBytesValue(fieldName,m,value)));
    }
 else {
      String opr=o.toString();
      if (opr.equalsIgnoreCase("String_Node_Str")) {
        log.error("String_Node_Str");
        throw new QueryHandlerException("String_Node_Str" + opr + "String_Node_Str");
      }
    }
  }
  indexClause.setExpressions(expr);
  clauses.add(indexClause);
  return clauses;
}
Program: 177033
Project: 177033
Buggy source:
@Override protected List<Object> handleAssociations(EntityMetadata m,Client client,List<EntitySaveGraph> graphs,List<String> relationNames,boolean isParent){
  log.debug("String_Node_Str");
  List<IndexClause> ixClause=prepareIndexClause();
  ((CassandraEntityReader)getReader()).setConditions(ixClause);
  List<EnhanceEntity> ls=reader.populateRelation(m,relationNames,isParent,client);
  return handleGraph(ls,graphs,client,m);
}

Fixed version (ground truth):
@Override protected List<Object> handleAssociations(EntityMetadata m,Client client,List<EntitySaveGraph> graphs,List<String> relationNames,boolean isParent){
  log.debug("String_Node_Str");
  List<IndexClause> ixClause=prepareIndexClause(m);
  ((CassandraEntityReader)getReader()).setConditions(ixClause);
  List<EnhanceEntity> ls=reader.populateRelation(m,relationNames,isParent,client);
  return handleGraph(ls,graphs,client,m);
}
Program: 177036
Project: 177036
Buggy source:
/** 
 * Gets the relations.
 * @return the relations
 */
public Map<String,Object> getRelations(){
  return Collections.unmodifiableMap(relations);
}

Fixed version (ground truth):
/** 
 * Gets the relations.
 * @return the relations
 */
public Map<String,Object> getRelations(){
  return relations != null ? Collections.unmodifiableMap(relations) : null;
}
Program: 177037
Project: 177037
Buggy source:
@Override public void addRelationIntoMetadata(Field relationField,EntityMetadata metadata){
  ManyToMany ann=relationField.getAnnotation(ManyToMany.class);
  Class<?> targetEntity=PropertyAccessorHelper.getGenericClass(relationField);
  if (null != ann.targetEntity() && !ann.targetEntity().getSimpleName().equals("String_Node_Str")) {
    targetEntity=ann.targetEntity();
  }
  validate(targetEntity);
  Relation relation=new Relation(relationField,targetEntity,relationField.getType(),ann.fetch(),Arrays.asList(ann.cascade()),Boolean.TRUE,ann.mappedBy(),Relation.ForeignKey.MANY_TO_MANY);
  boolean isJoinedByFK=relationField.isAnnotationPresent(JoinColumn.class);
  boolean isJoinedByTable=relationField.isAnnotationPresent(JoinTable.class);
  if (isJoinedByFK) {
    throw new PersistenceException("String_Node_Str");
  }
 else   if (isJoinedByTable) {
    JoinTableMetadata jtMetadata=new JoinTableMetadata(relationField);
    relation.setRelatedViaJoinTable(true);
    relation.setJoinTableMetadata(jtMetadata);
  }
 else {
    throw new PersistenceException("String_Node_Str");
  }
  metadata.addRelation(relationField.getName(),relation);
}

Fixed version (ground truth):
@Override public void addRelationIntoMetadata(Field relationField,EntityMetadata metadata){
  ManyToMany ann=relationField.getAnnotation(ManyToMany.class);
  Class<?> targetEntity=PropertyAccessorHelper.getGenericClass(relationField);
  if (null != ann.targetEntity() && !ann.targetEntity().getSimpleName().equals("String_Node_Str")) {
    targetEntity=ann.targetEntity();
  }
  validate(targetEntity);
  Relation relation=new Relation(relationField,targetEntity,relationField.getType(),ann.fetch(),Arrays.asList(ann.cascade()),Boolean.TRUE,ann.mappedBy(),Relation.ForeignKey.MANY_TO_MANY);
  boolean isJoinedByFK=relationField.isAnnotationPresent(JoinColumn.class);
  boolean isJoinedByTable=relationField.isAnnotationPresent(JoinTable.class);
  if (isJoinedByFK) {
    throw new PersistenceException("String_Node_Str");
  }
 else   if (isJoinedByTable) {
    JoinTableMetadata jtMetadata=new JoinTableMetadata(relationField);
    relation.setRelatedViaJoinTable(true);
    relation.setJoinTableMetadata(jtMetadata);
  }
 else   if (relation.getMappedBy() == null || relation.getMappedBy().isEmpty()) {
    throw new PersistenceException("String_Node_Str");
  }
  metadata.addRelation(relationField.getName(),relation);
  metadata.setRelationViaJoinTable(relation.isRelatedViaJoinTable());
}
Program: 177040
Project: 177040
Buggy source:
public Person getPerson(){
  return person;
}

Fixed version (ground truth):
public Person2 getPerson(){
  return person;
}