nus-yam/ex-repair huggingface dataset:
Program: 176943
Project: 176943
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof NodeLink)) {
    return false;
  }
  NodeLink targetNodeLink=(NodeLink)obj;
  return getSourceNodeId().equals(targetNodeLink.getSourceNodeId()) && getTargetNodeId().equals(targetNodeLink.getTargetNodeId());
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (!(obj instanceof NodeLink)) {
    return false;
  }
  NodeLink targetNodeLink=(NodeLink)obj;
  return new EqualsBuilder().append(getSourceNodeId(),targetNodeLink.getSourceNodeId()).append(getTargetNodeId(),targetNodeLink.getTargetNodeId()).isEquals();
}
Program: 176946
Project: 176946
Buggy source:
/** 
 * Writes an entity into Persistence cache
 */
public void persist(Object e){
  EntityMetadata metadata=getMetadata(e.getClass());
  getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState(),getPersistenceCache());
  Node headNode=graph.getHeadNode();
  if (headNode.getParents() == null) {
    headNode.setHeadNode(true);
  }
  headNode.persist();
  flush();
  getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  log.debug("String_Node_Str" + e.getClass());
}

Fixed version (ground truth):
/** 
 * Writes an entity into Persistence cache
 */
public void persist(Object e){
  EntityMetadata metadata=getMetadata(e.getClass());
  getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState(),getPersistenceCache());
  Node headNode=graph.getHeadNode();
  if (headNode.getParents() == null) {
    headNode.setHeadNode(true);
    getPersistenceCache().getMainCache().addHeadNode(headNode);
  }
  headNode.persist();
  flush();
  getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  log.debug("String_Node_Str" + e.getClass());
}
Program: 176948
Project: 176948
Buggy source:
/** 
 * Sets an object onto a field.
 * @param target the target
 * @param field the field
 * @param value the value
 * @throws PropertyAccessException the property access exception
 */
public static void set(Object target,Field field,Object value){
  if (!field.isAccessible()) {
    field.setAccessible(true);
  }
  try {
    field.set(target,value);
  }
 catch (  IllegalArgumentException iarg) {
    throw new PropertyAccessException(iarg);
  }
catch (  IllegalAccessException iacc) {
    throw new PropertyAccessException(iacc);
  }
}

Fixed version (ground truth):
/** 
 * Sets an object onto a field.
 * @param target the target
 * @param field the field
 * @param value the value
 * @throws PropertyAccessException the property access exception
 */
public static void set(Object target,Field field,Object value){
  if (target instanceof EnhanceEntity || value instanceof EnhanceEntity) {
    System.out.println("String_Node_Str");
  }
  if (!field.isAccessible()) {
    field.setAccessible(true);
  }
  try {
    field.set(target,value);
  }
 catch (  IllegalArgumentException iarg) {
    throw new PropertyAccessException(iarg);
  }
catch (  IllegalAccessException iacc) {
    throw new PropertyAccessException(iacc);
  }
}
Program: 176949
Project: 176949
Buggy source:
@Override public final <E>List<E> findAll(Class<E> entityClass,Object... rowIds){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  List<E> results=new ArrayList<E>();
  for (  Object rowKey : rowIds) {
    E r=(E)find(entityClass,entityMetadata,rowKey.toString(),null);
    if (r != null) {
      results.add(r);
    }
  }
  return results.isEmpty() ? null : results;
}

Fixed version (ground truth):
@Override public final <E>List<E> findAll(Class<E> entityClass,Object... rowIds){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  List<E> results=new ArrayList<E>();
  for (  Object rowKey : rowIds) {
    E r=(E)find(entityClass,entityMetadata,rowKey.toString(),entityMetadata.getRelationNames());
    if (r != null) {
      results.add(r);
    }
  }
  return results.isEmpty() ? null : results;
}
Program: 176950
Project: 176950
Buggy source:
/** 
 * On association using lucene.
 * @param m the m
 * @param client the client
 * @param ls the ls
 * @return the list
 */
protected List<EnhanceEntity> onAssociationUsingLucene(EntityMetadata m,Client client,List<EnhanceEntity> ls){
  Set<String> rSet=fetchDataFromLucene(client);
  List resultList=client.findAll(m.getEntityClazz(),rSet.toArray(new String[]{}));
  return transform(m,ls,resultList);
}

Fixed version (ground truth):
/** 
 * On association using lucene.
 * @param m the m
 * @param client the client
 * @param ls the ls
 * @return the list
 */
protected List<EnhanceEntity> onAssociationUsingLucene(EntityMetadata m,Client client,List<EnhanceEntity> ls){
  Set<String> rSet=fetchDataFromLucene(client);
  List resultList=client.findAll(m.getEntityClazz(),rSet.toArray(new String[]{}));
  return m.getRelationNames() != null && !m.getRelationNames().isEmpty() ? resultList : transform(m,ls,resultList);
}
Program: 176952
Project: 176952
Buggy source:
/** 
 * Updates the index for an object.
 * @param metadata the metadata
 * @param entity the entity
 */
public final void update(EntityMetadata metadata,Object entity,String parentId,Class<?> clazz){
  try {
    if (!MetadataUtils.useSecondryIndex(metadata.getPersistenceUnit())) {
      String id=PropertyAccessorHelper.getId(entity,metadata);
      boolean documentExists=indexer.entityExistsInIndex(entity.getClass());
      if (documentExists) {
        indexer.unindex(metadata,id);
      }
      indexer.index(metadata,entity,parentId,clazz);
    }
  }
 catch (  PropertyAccessException e) {
    throw new IndexingException("String_Node_Str" + metadata.getEntityClazz(),e);
  }
}

Fixed version (ground truth):
/** 
 * Updates the index for an object.
 * @param metadata the metadata
 * @param entity the entity
 */
public final void update(EntityMetadata metadata,Object entity,String parentId,Class<?> clazz){
  try {
    if (!MetadataUtils.useSecondryIndex(metadata.getPersistenceUnit())) {
      String id=PropertyAccessorHelper.getId(entity,metadata);
      boolean documentExists=indexer.entityExistsInIndex(entity.getClass());
      if (documentExists) {
        indexer.unindex(metadata,id);
        indexer.flush();
      }
      indexer.index(metadata,entity,parentId,clazz);
    }
  }
 catch (  PropertyAccessException e) {
    throw new IndexingException("String_Node_Str" + metadata.getEntityClazz(),e);
  }
}
Program: 176953
Project: 176953
Buggy source:
public <E>E merge(E e){
  log.debug("String_Node_Str" + e);
  EntityMetadata m=getMetadata(e.getClass());
  getEventDispatcher().fireEventListeners(m,e,PreUpdate.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new ManagedState(),getPersistenceCache());
  Node headNode=graph.getHeadNode();
  if (headNode.getParents() == null) {
    headNode.setHeadNode(true);
  }
  headNode.merge();
  flush();
  getEventDispatcher().fireEventListeners(m,e,PostUpdate.class);
  return e;
}

Fixed version (ground truth):
public <E>E merge(E e){
  log.debug("String_Node_Str" + e);
  EntityMetadata m=getMetadata(e.getClass());
  getEventDispatcher().fireEventListeners(m,e,PreUpdate.class);
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new ManagedState(),getPersistenceCache());
  Node headNode=graph.getHeadNode();
  if (headNode.getParents() == null) {
    headNode.setHeadNode(true);
  }
  headNode.merge();
  flush();
  getEventDispatcher().fireEventListeners(m,e,PostUpdate.class);
  return (E)headNode.getData();
}
Program: 176954
Project: 176954
Buggy source:
/** 
 * @param node
 * @param entityMetadata
 */
protected void indexNode(Node node,EntityMetadata entityMetadata,IndexManager indexManager){
  Map<NodeLink,Node> parents=node.getParents();
  if (parents != null) {
    for (    NodeLink parentNodeLink : parents.keySet()) {
      indexManager.write(entityMetadata,node.getData(),(String)parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE),parents.get(parentNodeLink).getDataClass());
    }
  }
 else {
    indexManager.write(entityMetadata,node.getData());
  }
}

Fixed version (ground truth):
/** 
 * @param node
 * @param entityMetadata
 */
protected void indexNode(Node node,EntityMetadata entityMetadata,IndexManager indexManager){
  Map<NodeLink,Node> parents=node.getParents();
  if (parents != null) {
    for (    NodeLink parentNodeLink : parents.keySet()) {
      indexManager.update(entityMetadata,node.getData(),(String)parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE),parents.get(parentNodeLink).getDataClass());
    }
  }
 else {
    indexManager.update(entityMetadata,node.getData(),null,null);
  }
}
Program: 176956
Project: 176956
Buggy source:
/** 
 * Updates the index for an object.
 * @param metadata the metadata
 * @param entity the entity
 */
public final void update(EntityMetadata metadata,Object entity){
  try {
    if (!MetadataUtils.useSecondryIndex(metadata.getPersistenceUnit())) {
      String id=PropertyAccessorHelper.getId(entity,metadata);
      indexer.unindex(metadata,id);
      indexer.index(metadata,entity);
    }
  }
 catch (  PropertyAccessException e) {
    throw new IndexingException("String_Node_Str" + metadata.getEntityClazz(),e);
  }
}

Fixed version (ground truth):
/** 
 * Updates the index for an object.
 * @param metadata the metadata
 * @param entity the entity
 */
public final void update(EntityMetadata metadata,Object entity,String parentId,Class<?> clazz){
  try {
    if (!MetadataUtils.useSecondryIndex(metadata.getPersistenceUnit())) {
      String id=PropertyAccessorHelper.getId(entity,metadata);
      boolean entityExists=indexer.entityExistsInIndex(entity.getClass());
      if (entityExists) {
        indexer.unindex(metadata,id);
      }
      indexer.index(metadata,entity,parentId,clazz);
    }
  }
 catch (  PropertyAccessException e) {
    throw new IndexingException("String_Node_Str" + metadata.getEntityClazz(),e);
  }
}
Program: 176957
Project: 176957
Buggy source:
@Override public void handleMerge(NodeStateContext nodeStateContext){
  nodeStateContext.setDirty(true);
  nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
  recursivelyPerformOperation(nodeStateContext,OPERATION.MERGE);
}

Fixed version (ground truth):
@Override public void handleMerge(NodeStateContext nodeStateContext){
  nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node)nodeStateContext);
  recursivelyPerformOperation(nodeStateContext,OPERATION.MERGE);
}
Program: 176958
Project: 176958
Buggy source:
/** 
 * Insert record in join table.
 * @param joinTableName the join table name
 * @param joinColumnName the join column name
 * @param inverseJoinColumnName the inverse join column name
 * @param relMetadata the rel metadata
 * @param parentId the parent id
 * @param child the child
 */
private void insertRecordInJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,Object parentId,Set<Object> childrenIds){
  Session s=getSessionInstance();
  Transaction tx=s.beginTransaction();
  for (  Object childId : childrenIds) {
    StringBuffer query=new StringBuffer();
    query.append("String_Node_Str").append(joinTableName).append("String_Node_Str").append(joinColumnName).append("String_Node_Str").append(inverseJoinColumnName).append("String_Node_Str").append("String_Node_Str").append(parentId).append("String_Node_Str").append(childId).append("String_Node_Str");
    s.createSQLQuery(query.toString()).executeUpdate();
  }
  tx.commit();
}

Fixed version (ground truth):
/** 
 * Insert record in join table.
 * @param joinTableName the join table name
 * @param joinColumnName the join column name
 * @param inverseJoinColumnName the inverse join column name
 * @param relMetadata the rel metadata
 * @param parentId the parent id
 * @param child the child
 */
private void insertRecordInJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,Object parentId,Set<Object> childrenIds){
  Session s=getStatefulSession();
  Transaction tx=s.beginTransaction();
  for (  Object childId : childrenIds) {
    StringBuffer query=new StringBuffer();
    query.append("String_Node_Str").append(joinTableName).append("String_Node_Str").append(joinColumnName).append("String_Node_Str").append(inverseJoinColumnName).append("String_Node_Str").append("String_Node_Str").append(parentId).append("String_Node_Str").append(childId).append("String_Node_Str");
    s.createSQLQuery(query.toString()).executeUpdate();
  }
  tx.commit();
}
Program: 176959
Project: 176959
Buggy source:
@Override public void delete(Object entity,Object pKey){
  Session s=getSessionInstance();
  Transaction tx=s.beginTransaction();
  s.delete(entity);
  tx.commit();
  s.close();
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(entity.getClass());
  if (!MetadataUtils.useSecondryIndex(getPersistenceUnit())) {
    getIndexManager().remove(metadata,entity,pKey.toString());
  }
}

Fixed version (ground truth):
@Override public void delete(Object entity,Object pKey){
  Session s=getStatefulSession();
  Transaction tx=s.beginTransaction();
  s.delete(entity);
  tx.commit();
  s.close();
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(entity.getClass());
  if (!MetadataUtils.useSecondryIndex(getPersistenceUnit())) {
    getIndexManager().remove(metadata,entity,pKey.toString());
  }
}
Program: 176960
Project: 176960
Buggy source:
public List<Object> findByRelation(String colName,String colValue,Class entityClazz){
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClazz);
  String tableName=m.getTableName();
  String aliasName="String_Node_Str" + tableName;
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(tableName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colValue);
  queryBuilder.append("String_Node_Str");
  Session s=getSessionInstance();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(queryBuilder.toString()).addEntity(m.getEntityClazz());
  return q.list();
}

Fixed version (ground truth):
public List<Object> findByRelation(String colName,String colValue,Class entityClazz){
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClazz);
  String tableName=m.getTableName();
  String aliasName="String_Node_Str" + tableName;
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(tableName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colValue);
  queryBuilder.append("String_Node_Str");
  Session s=getStatefulSession();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(queryBuilder.toString()).addEntity(m.getEntityClazz());
  return q.list();
}
Program: 176961
Project: 176961
Buggy source:
public void deleteByColumn(String tableName,String columnName,Object columnValue){
  StringBuffer query=new StringBuffer();
  query.append("String_Node_Str").append(tableName).append("String_Node_Str").append(columnName).append("String_Node_Str").append("String_Node_Str").append(columnValue).append("String_Node_Str");
  Session s=getSessionInstance();
  Transaction tx=s.beginTransaction();
  s.createSQLQuery(query.toString()).executeUpdate();
  tx.commit();
}

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

Fixed version (ground truth):
/** 
 * Find.
 * @param nativeQuery the native fquery
 * @param relations the relations
 * @param m the m
 * @return the list
 */
public List find(String nativeQuery,List<String> relations,EntityMetadata m){
  List<Object[]> result=new ArrayList<Object[]>();
  s=sf.openStatelessSession();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(nativeQuery).addEntity(m.getEntityClazz());
  for (  String r : relations) {
    if (!m.getIdColumn().getName().equalsIgnoreCase(r)) {
      q.addScalar(r);
    }
  }
  return q.list();
}
Program: 176963
Project: 176963
Buggy source:
@Override public void persist(Node node){
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
  String id=ObjectGraphBuilder.getEntityId(node.getNodeId());
  Session s;
  Transaction tx;
  try {
    s=getSessionInstance();
    tx=s.beginTransaction();
    s.persist(node.getData());
    tx.commit();
  }
 catch (  org.hibernate.exception.ConstraintViolationException e) {
    log.info(e.getMessage());
  }
catch (  HibernateException e) {
    log.info(e.getMessage());
  }
  List<RelationHolder> relationHolders=getRelationHolders(node);
  for (  RelationHolder rh : relationHolders) {
    String linkName=rh.getRelationName();
    String linkValue=rh.getRelationValue();
    if (linkName != null && linkValue != null) {
      s=getSessionInstance();
      tx=s.beginTransaction();
      String updateSql="String_Node_Str" + metadata.getTableName() + "String_Node_Str"+ linkName+ "String_Node_Str"+ linkValue+ "String_Node_Str"+ metadata.getIdColumn().getName()+ "String_Node_Str"+ id+ "String_Node_Str";
      s.createSQLQuery(updateSql).executeUpdate();
      tx.commit();
    }
  }
  if (!MetadataUtils.useSecondryIndex(getPersistenceUnit())) {
    indexNode(node,metadata,getIndexManager());
  }
}

Fixed version (ground truth):
@Override public void persist(Node node){
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
  String id=ObjectGraphBuilder.getEntityId(node.getNodeId());
  try {
    s=getStatelessSession();
    Transaction tx=s.beginTransaction();
    s.insert(node.getData());
    tx.commit();
  }
 catch (  org.hibernate.exception.ConstraintViolationException e) {
    log.info(e.getMessage());
  }
catch (  HibernateException e) {
    log.info(e.getMessage());
  }
  List<RelationHolder> relationHolders=getRelationHolders(node);
  for (  RelationHolder rh : relationHolders) {
    String linkName=rh.getRelationName();
    String linkValue=rh.getRelationValue();
    if (linkName != null && linkValue != null) {
      s=getStatelessSession();
      Transaction tx=s.beginTransaction();
      String updateSql="String_Node_Str" + metadata.getTableName() + "String_Node_Str"+ linkName+ "String_Node_Str"+ linkValue+ "String_Node_Str"+ metadata.getIdColumn().getName()+ "String_Node_Str"+ id+ "String_Node_Str";
      s.createSQLQuery(updateSql).executeUpdate();
      tx.commit();
    }
  }
  if (!MetadataUtils.useSecondryIndex(getPersistenceUnit())) {
    indexNode(node,metadata,getIndexManager());
  }
}
Program: 176964
Project: 176964
Buggy source:
public static void clearPersistenceCache(){
  PersistenceCache pc=PersistenceCache.INSTANCE;
  pc.clean();
}

Fixed version (ground truth):
public void clearPersistenceCache(){
  persistenceCache.clean();
}
Program: 176965
Project: 176965
Buggy source:
public static String getNodeId(Object pk,Class<?> objectClass){
  return objectClass.getName() + Constants.NODE_ID_SEPARATOR + (String)pk;
}

Fixed version (ground truth):
public static String getNodeId(Object pk,Class<?> objectClass){
  return objectClass.getName() + Constants.NODE_ID_SEPARATOR + pk.toString();
}
Program: 176969
Project: 176969
Buggy source:
@Override public void addRelationIntoMetadata(Field relationField,EntityMetadata metadata){
  OneToMany ann=relationField.getAnnotation(OneToMany.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.ONE_TO_MANY);
  boolean isJoinedByFK=relationField.isAnnotationPresent(JoinColumn.class);
  boolean isJoinedByTable=relationField.isAnnotationPresent(JoinTable.class);
  if (isJoinedByFK) {
    JoinColumn joinColumnAnn=relationField.getAnnotation(JoinColumn.class);
    relation.setJoinColumnName(joinColumnAnn.name());
  }
 else   if (isJoinedByTable) {
    JoinTableMetadata jtMetadata=new JoinTableMetadata(relationField);
    relation.setRelatedViaJoinTable(true);
    relation.setJoinTableMetadata(jtMetadata);
  }
  metadata.addRelation(relationField.getName(),relation);
}

Fixed version (ground truth):
@Override public void addRelationIntoMetadata(Field relationField,EntityMetadata metadata){
  OneToMany ann=relationField.getAnnotation(OneToMany.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.ONE_TO_MANY);
  boolean isJoinedByFK=relationField.isAnnotationPresent(JoinColumn.class);
  boolean isJoinedByTable=relationField.isAnnotationPresent(JoinTable.class);
  if (isJoinedByFK) {
    JoinColumn joinColumnAnn=relationField.getAnnotation(JoinColumn.class);
    relation.setJoinColumnName(joinColumnAnn.name());
  }
 else   if (isJoinedByTable) {
    JoinTableMetadata jtMetadata=new JoinTableMetadata(relationField);
    relation.setRelatedViaJoinTable(true);
    relation.setJoinTableMetadata(jtMetadata);
  }
  metadata.addRelation(relationField.getName(),relation);
  metadata.setParent(true);
}
Program: 176970
Project: 176970
Buggy source:
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    return (EnhanceEntity)client.find(m.getEntityClazz(),primaryKey.toString());
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
    throw new PersistenceException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  return super.findById(primaryKey,m,relationNames,client);
}
Program: 176971
Project: 176971
Buggy source:
@Override public void handleFind(NodeStateContext nodeStateContext){
  Client client=nodeStateContext.getClient();
  Class<?> nodeDataClass=nodeStateContext.getDataClass();
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(nodeDataClass);
  String entityId=ObjectGraphBuilder.getEntityId(nodeStateContext.getNodeId());
  List<String> linkNames=new ArrayList<String>();
  for (  Relation relation : entityMetadata.getRelations()) {
    linkNames.add(relation.getJoinColumnName());
  }
  Object nodeData=null;
  EntityReader reader=client.getReader();
  EnhanceEntity enhanceEntity=reader.findById(entityId,entityMetadata,linkNames,client);
  if (enhanceEntity != null && enhanceEntity.getEntity() != null) {
    Object entity=enhanceEntity.getEntity();
    if (linkNames.isEmpty() && !entityMetadata.isRelationViaJoinTable()) {
      nodeData=entity;
    }
 else {
      nodeData=reader.recursivelyFindEntities(enhanceEntity,client,entityMetadata,nodeStateContext.getPersistenceDelegator());
    }
  }
  nodeStateContext.setData(nodeData);
  nodeStateContext.setDirty(false);
  ObjectGraph graph=new ObjectGraphBuilder().getObjectGraph(nodeData,new ManagedState());
  PersistenceCache.INSTANCE.getMainCache().addGraphToCache(graph);
}

Fixed version (ground truth):
@Override public void handleFind(NodeStateContext nodeStateContext){
  Client client=nodeStateContext.getClient();
  Class<?> nodeDataClass=nodeStateContext.getDataClass();
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(nodeDataClass);
  String entityId=ObjectGraphBuilder.getEntityId(nodeStateContext.getNodeId());
  List<String> linkNames=new ArrayList<String>();
  for (  Relation relation : entityMetadata.getRelations()) {
    linkNames.add(relation.getJoinColumnName());
  }
  Object nodeData=null;
  EntityReader reader=client.getReader();
  EnhanceEntity enhanceEntity=reader.findById(entityId,entityMetadata,entityMetadata.getRelationNames(),client);
  if (enhanceEntity != null && enhanceEntity.getEntity() != null) {
    Object entity=enhanceEntity.getEntity();
    if (linkNames.isEmpty() && !entityMetadata.isRelationViaJoinTable()) {
      nodeData=entity;
    }
 else {
      nodeData=reader.recursivelyFindEntities(enhanceEntity,client,entityMetadata,nodeStateContext.getPersistenceDelegator());
    }
  }
  nodeStateContext.setData(nodeData);
  nodeStateContext.setDirty(false);
  ObjectGraph graph=new ObjectGraphBuilder().getObjectGraph(nodeData,new ManagedState());
  PersistenceCache.INSTANCE.getMainCache().addGraphToCache(graph);
}
Program: 176972
Project: 176972
Buggy source:
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),primaryKey);
    if (o == null) {
      return null;
    }
 else {
      return o instanceof EnhanceEntity ? (EnhanceEntity)o : new EnhanceEntity(o,getId(o,m),null);
    }
  }
 catch (  Exception e) {
    throw new PersistenceException(e);
  }
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  return super.findById(primaryKey,m,relationNames,client);
}
Program: 176973
Project: 176973
Buggy source:
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),primaryKey);
    if (o == null) {
      return null;
    }
 else {
      return o instanceof EnhanceEntity ? (EnhanceEntity)o : new EnhanceEntity(o,getId(o,m),null);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new PersistenceException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  return super.findById(primaryKey,m,relationNames,client);
}
Program: 176974
Project: 176974
Buggy source:
/** 
 * Populate p key.
 * @param entity the entity
 * @param associatedEntity the associated entity
 * @param metadata the metadata
 */
private void populatePKey(Object entity,Object associatedEntity,EntityMetadata metadata){
  if (associatedEntity != null) {
    Class<?> clazz=associatedEntity.getClass();
    if (associatedEntity instanceof HibernateProxy) {
      clazz=associatedEntity.getClass().getSuperclass();
    }
    Field[] fields=clazz.getDeclaredFields();
    Field f=null;
    for (    Field field : fields) {
      if (field.isAnnotationPresent(Id.class)) {
        f=field;
        break;
      }
    }
    try {
      PropertyAccessorHelper.setId(associatedEntity,metadata,getId(entity,metadata));
    }
 catch (    PropertyAccessException e) {
      throw new PersistenceObjectGraphBuilderException("String_Node_Str" + entity + "String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Populate p key.
 * @param entity the entity
 * @param associatedEntity the associated entity
 * @param metadata the metadata
 */
private void populatePKey(Object entity,Object associatedEntity,EntityMetadata metadata){
  if (associatedEntity != null) {
    Class<?> clazz=associatedEntity.getClass();
    if (associatedEntity instanceof HibernateProxy) {
      clazz=associatedEntity.getClass().getSuperclass();
    }
    Field[] fields=clazz.getDeclaredFields();
    Field f=null;
    for (    Field field : fields) {
      if (field.isAnnotationPresent(Id.class)) {
        f=field;
        break;
      }
    }
    try {
      PropertyAccessorHelper.setId(associatedEntity,KunderaMetadataManager.getEntityMetadata(clazz),getId(entity,metadata));
    }
 catch (    PropertyAccessException e) {
      throw new PersistenceObjectGraphBuilderException("String_Node_Str" + entity + "String_Node_Str",e);
    }
  }
}
Program: 176975
Project: 176975
Buggy source:
@Override public void persistJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,EntityMetadata relMetadata,Object primaryKey,Object childEntity){
  Mutator mutator=Pelops.createMutator(PelopsUtils.generatePoolName(getPersistenceUnit()));
  String parentId=(String)primaryKey;
  List<Column> columns=new ArrayList<Column>();
  if (Collection.class.isAssignableFrom(childEntity.getClass())) {
    Collection children=(Collection)childEntity;
    for (    Object child : children) {
      addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,child);
    }
  }
 else {
    addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,childEntity);
  }
  mutator.writeColumns(joinTableName,new Bytes(parentId.getBytes()),Arrays.asList(columns.toArray(new Column[0])));
  mutator.execute(ConsistencyLevel.ONE);
}

Fixed version (ground truth):
@Override public void persistJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,EntityMetadata relMetadata,Object primaryKey,Object childEntity){
  String poolName=PelopsUtils.generatePoolName(getPersistenceUnit());
  Mutator mutator=Pelops.createMutator(poolName);
  String parentId=(String)primaryKey;
  List<Column> columns=new ArrayList<Column>();
  if (Collection.class.isAssignableFrom(childEntity.getClass())) {
    Collection children=(Collection)childEntity;
    for (    Object child : children) {
      addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,child);
    }
  }
 else {
    addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,childEntity);
  }
  createIndexesOnColumns(joinTableName,poolName,columns);
  mutator.writeColumns(joinTableName,new Bytes(parentId.getBytes()),Arrays.asList(columns.toArray(new Column[0])));
  mutator.execute(ConsistencyLevel.ONE);
}
Program: 176977
Project: 176977
Buggy source:
/** 
 * Extract entity field.
 * @param entity the entity
 * @param dbObj the db obj
 * @param column the column
 * @throws PropertyAccessException the property access exception
 */
private void extractEntityField(Object entity,BasicDBObject dbObj,Column column) throws PropertyAccessException {
  if (column.getField().getType().equals(List.class) || column.getField().getType().equals(Set.class)) {
    Collection collection=(Collection)PropertyAccessorHelper.getObject(entity,column.getField());
    BasicDBList basicDBList=new BasicDBList();
    for (    Object o : collection) {
      basicDBList.add(o);
    }
    dbObj.put(column.getName(),basicDBList);
  }
 else {
    Object valObj=PropertyAccessorHelper.getObject(entity,column.getField());
    dbObj.put(column.getName(),valObj instanceof Calendar ? ((Calendar)valObj).getTime().toString() : PropertyAccessorHelper.getObject(entity,column.getField()).toString());
  }
}

Fixed version (ground truth):
/** 
 * Extract entity field.
 * @param entity the entity
 * @param dbObj the db obj
 * @param column the column
 * @throws PropertyAccessException the property access exception
 */
private void extractEntityField(Object entity,BasicDBObject dbObj,Column column) throws PropertyAccessException {
  if (column.getField().getType().isAssignableFrom(List.class) || column.getField().getType().isAssignableFrom(Set.class)) {
    Collection collection=(Collection)PropertyAccessorHelper.getObject(entity,column.getField());
    BasicDBList basicDBList=new BasicDBList();
    for (    Object o : collection) {
      basicDBList.add(o);
    }
    dbObj.put(column.getName(),basicDBList);
  }
 else   if (column.getField().getType().isAssignableFrom(Map.class)) {
    Map mapObj=(Map)PropertyAccessorHelper.getObject(entity,column.getField());
    BasicDBObjectBuilder builder=BasicDBObjectBuilder.start(mapObj);
    dbObj.put(column.getName(),builder.get());
  }
 else {
    Object valObj=PropertyAccessorHelper.getObject(entity,column.getField());
    dbObj.put(column.getName(),valObj instanceof Calendar ? ((Calendar)valObj).getTime().toString() : PropertyAccessorHelper.getObject(entity,column.getField()).toString());
  }
}
Program: 176980
Project: 176980
Buggy source:
@Override public <E>List<E> findParentEntityFromJoinTable(EntityMetadata parentMetadata,String joinTableName,String joinColumnName,String inverseJoinColumnName,Object childId){
  return null;
}

Fixed version (ground truth):
@Override public <E>List<E> findParentEntityFromJoinTable(EntityMetadata parentMetadata,String joinTableName,String joinColumnName,String inverseJoinColumnName,Object childId){
  return handler.findParentEntityFromJoinTable(parentMetadata,joinTableName,joinColumnName,inverseJoinColumnName,childId);
}
Program: 176982
Project: 176982
Buggy source:
/** 
 * Returns list of managed urls.
 * @return
 */
public List<URL> getManagedURLs(){
  List<URL> managedURL=getJarFileUrls();
  if (managedURL == null && !getExcludeUnlistedClasses()) {
    managedURL=new ArrayList<URL>(1);
    managedURL.add(getPersistenceUnitRootUrl());
  }
  return managedURL;
}

Fixed version (ground truth):
/** 
 * Returns list of managed urls.
 * @return
 */
public List<URL> getManagedURLs(){
  List<URL> managedURL=getJarFileUrls();
  if (managedURL == null) {
    managedURL=new ArrayList<URL>(1);
  }
  if (!getExcludeUnlistedClasses()) {
    managedURL.add(getPersistenceUnitRootUrl());
  }
  return managedURL;
}
Program: 176983
Project: 176983
Buggy source:
@Override public void persistJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,EntityMetadata relMetadata,EntitySaveGraph objectGraph){
  Mutator mutator=Pelops.createMutator(PelopsUtils.generatePoolName(getPersistenceUnit()));
  String parentId=objectGraph.getParentId();
  List<Column> columns=new ArrayList<Column>();
  if (Collection.class.isAssignableFrom(objectGraph.getChildEntity().getClass())) {
    Collection children=(Collection)objectGraph.getChildEntity();
    for (    Object child : children) {
      addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,child);
    }
  }
 else {
    Object child=objectGraph.getChildEntity();
    addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,child);
  }
  mutator.writeColumns(joinTableName,new Bytes(parentId.getBytes()),Arrays.asList(columns.toArray(new Column[0])));
  mutator.execute(ConsistencyLevel.ONE);
}

Fixed version (ground truth):
@Override public void persistJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,EntityMetadata relMetadata,Object primaryKey,Object childEntity){
  Mutator mutator=Pelops.createMutator(PelopsUtils.generatePoolName(getPersistenceUnit()));
  String parentId=(String)primaryKey;
  List<Column> columns=new ArrayList<Column>();
  if (Collection.class.isAssignableFrom(childEntity.getClass())) {
    Collection children=(Collection)childEntity;
    for (    Object child : children) {
      addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,child);
    }
  }
 else {
    addColumnsToJoinTable(inverseJoinColumnName,relMetadata,columns,childEntity);
  }
  mutator.writeColumns(joinTableName,new Bytes(parentId.getBytes()),Arrays.asList(columns.toArray(new Column[0])));
  mutator.execute(ConsistencyLevel.ONE);
}
Program: 176984
Project: 176984
Buggy source:
/** 
 * Inserts records into Join Table.
 * @param joinTableName Name of Join Table
 * @param joinColumnName Name of Join Column
 * @param inverseJoinColumnName Name of Inverse Join Column
 * @param relMetadata Entity metadata for the child entity (i.e. entity at the otherside of the relationship)
 * @param objectGraph Object graph of the persistence (Includes parent and childdata and other related info)
 */
void persistJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,EntityMetadata relMetadata,EntitySaveGraph objectGraph);

Fixed version (ground truth):
/** 
 * Inserts records into Join Table.
 * @param joinTableName Name of Join Table
 * @param joinColumnName Name of Join Column
 * @param inverseJoinColumnName Name of Inverse Join Column
 * @param relMetadata Entity metadata for the child entity (i.e. entity at the otherside of the relationship)
 * @param primaryKey TODO
 * @param childEntity TODO
 */
void persistJoinTable(String joinTableName,String joinColumnName,String inverseJoinColumnName,EntityMetadata relMetadata,Object primaryKey,Object childEntity);
Program: 176987
Project: 176987
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 : 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();
  }
}

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) {
          if (entityObj != null) {
            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: 176988
Project: 176988
Buggy source:
@Override public List<?> getResultList(){
  log.info("String_Node_Str" + query);
  List results=null;
  try {
    EntityMetadata m=kunderaQuery.getEntityMetadata();
    Client client=persistenceDelegeator.getClient(m);
    List<EntitySaveGraph> graphs=persistenceDelegeator.getGraph(m.getEntityClazz().newInstance(),m);
    Map<Boolean,List<String>> relationHolder=persistenceDelegeator.getRelations(graphs,m.getEntityClazz());
    List<String> relationNames=relationHolder.values().iterator().next();
    boolean isParent=relationHolder.keySet().iterator().next();
    if (relationNames.isEmpty()) {
      results=populateEntities(m,client);
    }
 else {
      results=handleAssociations(m,client,graphs,relationNames,isParent);
    }
  }
 catch (  InstantiationException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
catch (  IllegalAccessException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
  return results != null && !results.isEmpty() ? results : null;
}

Fixed version (ground truth):
@Override public List<?> getResultList(){
  log.info("String_Node_Str" + query);
  List results=null;
  try {
    EntityMetadata m=kunderaQuery.getEntityMetadata();
    Client client=persistenceDelegeator.getClient(m);
    List<EntitySaveGraph> graphs=persistenceDelegeator.getGraph(m.getEntityClazz().newInstance(),m);
    Map<Boolean,List<String>> relationHolder=persistenceDelegeator.getRelations(graphs,m.getEntityClazz());
    List<String> relationNames=relationHolder.values().iterator().next();
    boolean isParent=relationHolder.keySet().iterator().next();
    if (relationNames.isEmpty() && !m.isRelationViaJoinTable()) {
      results=populateEntities(m,client);
    }
 else {
      results=handleAssociations(m,client,graphs,relationNames,isParent);
    }
  }
 catch (  InstantiationException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
catch (  IllegalAccessException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
  return results != null && !results.isEmpty() ? results : null;
}
Program: 176990
Project: 176990
Buggy source:
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),m,primaryKey,relationNames);
    return o instanceof EnhanceEntity ? (EnhanceEntity)o : new EnhanceEntity(o,getId(o,m),null);
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new PersistenceException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(Object primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  try {
    Object o=client.find(m.getEntityClazz(),m,primaryKey,relationNames);
    if (o == null) {
      return null;
    }
 else {
      return o instanceof EnhanceEntity ? (EnhanceEntity)o : new EnhanceEntity(o,getId(o,m),null);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new PersistenceException(e.getMessage());
  }
}
Program: 176991
Project: 176991
Buggy source:
public List<Object> find(String colName,String colValue,EntityMetadata m){
  String tableName=m.getTableName();
  String aliasName="String_Node_Str" + tableName;
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(tableName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colValue);
  Session s=getSessionInstance();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(queryBuilder.toString()).addEntity(m.getEntityClazz());
  return q.list();
}

Fixed version (ground truth):
public List<Object> find(String colName,String colValue,EntityMetadata m){
  String tableName=m.getTableName();
  String aliasName="String_Node_Str" + tableName;
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(tableName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(colValue);
  queryBuilder.append("String_Node_Str");
  Session s=getSessionInstance();
  s.beginTransaction();
  SQLQuery q=s.createSQLQuery(queryBuilder.toString()).addEntity(m.getEntityClazz());
  return q.list();
}
Program: 176993
Project: 176993
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());
  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;
}

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);
  try {
    if (!result.isEmpty()) {
      ls=new ArrayList<EnhanceEntity>(result.size());
      for (      Object o : result) {
        Class clazz=m.getEntityClazz();
        Object entity=clazz.newInstance();
        boolean noRelationFound=true;
        if (!o.getClass().isAssignableFrom(clazz)) {
          entity=((Object[])o)[0];
          noRelationFound=false;
        }
 else {
          entity=o;
        }
        EnhanceEntity e=new EnhanceEntity(entity,getId(entity,m),noRelationFound ? null : populateRelations(relationNames,(Object[])o));
        ls.add(e);
      }
    }
  }
 catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
  return ls;
}