nus-yam/ex-repair huggingface dataset:
Program: 90424
Project: 90424
Buggy source:
/** 
 * @param clazz
 * @param field
 * @return
 */
public static Field getField(Class<?> clazz,String fieldName){
  Field field=_aliasFieldCache.get(clazz.getName() + fieldName);
  if (field == null) {
    try {
      field=clazz.getDeclaredField(fieldName);
    }
 catch (    Exception e) {
    }
  }
  if (field == null) {
    Class<?> superClass=clazz.getSuperclass();
    if (superClass != null) {
      field=getField(superClass,fieldName);
    }
  }
  return field;
}

Fixed version (ground truth):
/** 
 * 支持通过别名获取Field
 * @param clazz
 * @param field
 * @return
 */
public static Field getField(Class<?> clazz,String fieldName){
  Field field=_aliasFieldCache.get(clazz.getName() + fieldName);
  if (field == null) {
    try {
      field=clazz.getDeclaredField(fieldName);
    }
 catch (    Exception e) {
    }
  }
  if (field == null) {
    Class<?> superClass=clazz.getSuperclass();
    if (superClass != null) {
      field=getField(superClass,fieldName);
    }
  }
  return field;
}
Program: 90425
Project: 90425
Buggy source:
public OrderBy(String field,Order order,Class<?> clazz){
  if (clazz != null)   this.field=BeansUtil.getFieldName(BeansUtil.getField(clazz,field));
 else   this.field=field;
  this.order=order;
}

Fixed version (ground truth):
public OrderBy(String field,Order order,Class<?> clazz){
  Field f=BeansUtil.getField(clazz,field);
  if (clazz != null)   this.field=BeansUtil.getFieldName(f);
 else   this.field=field;
  this.fieldType=f.getType();
  this.order=order;
}
Program: 90426
Project: 90426
Buggy source:
@Override public String toString(){
  StringBuilder info=new StringBuilder();
  if (fields != null && fields.length > 0) {
    info.append("String_Node_Str");
    for (    String field : fields) {
      info.append(field).append("String_Node_Str");
    }
    info.deleteCharAt(info.length() - 1);
  }
  if (StringUtil.isNotBlank(getWhereSql())) {
    info.append("String_Node_Str").append(getWhereSql());
  }
  return info.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + field + "String_Node_Str"+ fieldType+ "String_Node_Str"+ order+ "String_Node_Str";
}
Program: 90427
Project: 90427
Buggy source:
public ResultSetableQueryImpl(Class<T> clazz){
  this.clazz=clazz;
}

Fixed version (ground truth):
public ResultSetableQueryImpl(Class<T> clazz){
  super.clazz=clazz;
}
Program: 90429
Project: 90429
Buggy source:
/** 
 * 通过反射获取对象的属性值.
 * @param obj 被反射对象
 * @param propertyName 属性名
 * @return 属性值
 * @throws Exception 操作失败
 */
public static Object getProperty(Object obj,String propertyName){
  Field f=getField(obj.getClass(),propertyName);
  f.setAccessible(true);
  try {
    return f.get(obj);
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * 通过反射获取对象的属性值.
 * @param obj 被反射对象
 * @param propertyName 属性名
 * @return 属性值
 * @throws Exception 操作失败
 */
public static Object getProperty(Object obj,String propertyName){
  Field f=getField(obj.getClass(),propertyName);
  if (f == null) {
    throw new IllegalArgumentException("String_Node_Str" + propertyName + "String_Node_Str"+ obj.getClass());
  }
  f.setAccessible(true);
  try {
    return f.get(obj);
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 90430
Project: 90430
Buggy source:
@Override public void afterPropertiesSet() throws Exception {
  super.init();
  DefaultListableBeanFactory beanFactory=(DefaultListableBeanFactory)appCtx.getAutowireCapableBeanFactory();
  IContainer<DataSource> dsC=this.getDBCluster().getDBConnectionPool().getAllDataSources();
  BeanDefinition dsBean=null;
  DataSource ds=null;
  for (  String key : dsC.keys()) {
    ds=dsC.find(key);
    dsBean=new RootBeanDefinition(ds.getClass());
    beanFactory.registerBeanDefinition(key,dsBean);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",key);
    }
  }
}

Fixed version (ground truth):
@Override public void afterPropertiesSet() throws Exception {
  super.init();
  DefaultListableBeanFactory beanFactory=(DefaultListableBeanFactory)appCtx.getAutowireCapableBeanFactory();
  IDBConnectionPool dbConnectionPool=this.getDBCluster().getDBConnectionPool();
  IContainer<DataSource> dsC=dbConnectionPool.getAllDataSources();
  BeanDefinition dsBean=null;
  DataSource ds=null;
  for (  String key : dsC.keys()) {
    ds=dsC.find(key);
    dsBean=createBeanDef(ds);
    ((AbstractBeanDefinition)dsBean).setDestroyMethodName("String_Node_Str");
    beanFactory.registerBeanDefinition(key,dsBean);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",key);
    }
  }
}
Program: 90431
Project: 90431
Buggy source:
@Test public void testInjectDaaSource(){
  DataSource pinusGlobal=(DataSource)appCtx.getBean("String_Node_Str");
  Assert.assertNotNull(pinusGlobal);
  DataSource pinusSharding1=(DataSource)appCtx.getBean("String_Node_Str");
  Assert.assertNotNull(pinusSharding1);
  DataSource pinusSharding2=(DataSource)appCtx.getBean("String_Node_Str");
  Assert.assertNotNull(pinusSharding2);
}

Fixed version (ground truth):
@Test public void testInjectDaaSource() throws Exception {
  DataSource pinusGlobal=(DataSource)appCtx.getBean("String_Node_Str");
  Assert.assertNotNull(pinusGlobal);
  Assert.assertFalse(pinusGlobal.getConnection().isClosed());
  DataSource pinusSharding1=(DataSource)appCtx.getBean("String_Node_Str");
  Assert.assertFalse(pinusSharding1.getConnection().isClosed());
  DataSource pinusSharding2=(DataSource)appCtx.getBean("String_Node_Str");
  Assert.assertNotNull(pinusSharding2);
  Assert.assertFalse(pinusSharding2.getConnection().isClosed());
}
Program: 90432
Project: 90432
Buggy source:
private <T>void _put(String key,Map<EntityPK,T> param){
  if (param == null || param.isEmpty()) {
    return;
  }
  ShardedJedis redisClient=null;
  try {
    redisClient=jedisPool.getResource();
    Map<byte[],byte[]> data=Maps.newLinkedHashMap();
    for (    Map.Entry<EntityPK,T> entry : param.entrySet()) {
      data.put(IOUtil.getBytesByJava(entry.getKey()),IOUtil.getBytes(entry.getValue()));
    }
    redisClient.hmset(key.getBytes(),data);
    redisClient.exists(key.getBytes());
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + data.size() + "String_Node_Str"+ key);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str" + e.getMessage());
  }
 finally {
    if (redisClient != null)     redisClient.close();
  }
}

Fixed version (ground truth):
private <T>void _put(String key,Map<EntityPK,T> param){
  if (param == null || param.isEmpty()) {
    return;
  }
  ShardedJedis redisClient=null;
  try {
    redisClient=jedisPool.getResource();
    Map<byte[],byte[]> data=Maps.newLinkedHashMap();
    for (    Map.Entry<EntityPK,T> entry : param.entrySet()) {
      data.put(IOUtil.getBytesByJava(entry.getKey()),IOUtil.getBytes(entry.getValue()));
    }
    redisClient.hmset(key.getBytes(),data);
    redisClient.expire(key.getBytes(),expire);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + data.size() + "String_Node_Str"+ key);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str" + e.getMessage());
  }
 finally {
    if (redisClient != null)     redisClient.close();
  }
}
Program: 90435
Project: 90435
Buggy source:
/** 
 * 获取当前使用的数据库集群.
 * @return 数据库集群
 */
IDBCluster getDBCluster();

Fixed version (ground truth):
/** 
 * / 获取当前使用的数据库集群.
 * @return 数据库集群
 */
IDBCluster getDBCluster();
Program: 90436
Project: 90436
Buggy source:
@Override public Number count(){
  Number count=0;
  if (entityMetaManager.isShardingEntity(clazz)) {
    count=this.shardingQuery.getCountByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
 else {
    count=this.globalQuery.getCountByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
  return count;
}

Fixed version (ground truth):
@Override public Number count(){
  Number count=0;
  if (entityMetaManager.isShardingEntity(clazz)) {
    if (this.shardingKey != null)     count=this.shardingQuery.getCountByQuery(this,this.shardingKey,this.clazz,this.useCache,this.masterSlave);
 else     count=this.shardingQuery.getCountByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
 else {
    count=this.globalQuery.getCountByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
  return count;
}
Program: 90437
Project: 90437
Buggy source:
@Override public IQuery<T> clone(){
  ResultSetableQueryImpl<T> clone=new ResultSetableQueryImpl<T>(this.clazz);
  clone.fields=this.fields;
  clone.condList.addAll(this.condList);
  clone.orderList.addAll(this.orderList);
  clone.start=this.start;
  clone.limit=this.limit;
  clone.globalQuery=this.globalQuery;
  clone.shardingQuery=this.shardingQuery;
  clone.useCache=this.useCache;
  clone.masterSlave=this.masterSlave;
  clone.entityMetaManager=this.entityMetaManager;
  return clone;
}

Fixed version (ground truth):
@Override public IQuery<T> clone(){
  ResultSetableQueryImpl<T> clone=new ResultSetableQueryImpl<T>(this.clazz);
  clone.fields=this.fields;
  clone.condList.addAll(this.condList);
  clone.orderList.addAll(this.orderList);
  clone.start=this.start;
  clone.limit=this.limit;
  clone.globalQuery=this.globalQuery;
  clone.shardingQuery=this.shardingQuery;
  clone.shardingKey=this.shardingKey;
  clone.useCache=this.useCache;
  clone.masterSlave=this.masterSlave;
  clone.entityMetaManager=this.entityMetaManager;
  return clone;
}
Program: 90438
Project: 90438
Buggy source:
@Override public List<T> list(){
  List<T> result=null;
  List<EntityPK> entityPkList=coverToEntityPK();
  if (entityMetaManager.isShardingEntity(clazz)) {
    if (entityPkList != null && !entityPkList.isEmpty())     result=this.shardingQuery.findByPkList(entityPkList,this.clazz,this.useCache,this.masterSlave);
 else     result=this.shardingQuery.findByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
 else {
    if (entityPkList != null && !entityPkList.isEmpty())     result=this.globalQuery.findByPkList(entityPkList,this.clazz,this.useCache,this.masterSlave);
 else     result=this.globalQuery.findByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
  return result;
}

Fixed version (ground truth):
@Override public List<T> list(){
  List<T> result=null;
  List<EntityPK> entityPkList=coverToEntityPK();
  if (entityMetaManager.isShardingEntity(clazz)) {
    if (entityPkList != null && !entityPkList.isEmpty())     if (this.shardingKey != null)     result=this.shardingQuery.findByPkList(entityPkList,this.shardingKey,this.clazz,this.useCache,this.masterSlave);
 else     result=this.shardingQuery.findByPkList(entityPkList,this.clazz,this.useCache,this.masterSlave);
 else     if (this.shardingKey != null)     result=this.shardingQuery.findByQuery(this,this.shardingKey,this.clazz,this.useCache,this.masterSlave);
 else     result=this.shardingQuery.findByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
 else {
    if (entityPkList != null && !entityPkList.isEmpty())     result=this.globalQuery.findByPkList(entityPkList,this.clazz,this.useCache,this.masterSlave);
 else     result=this.globalQuery.findByQuery(this,this.clazz,this.useCache,this.masterSlave);
  }
  return result;
}
Program: 90439
Project: 90439
Buggy source:
/** 
 * 执行保存数据操作.
 * @param conn 数据库连接
 * @param entities 需要被保存的数据
 * @param tableIndex 分片表下标. 当-1时忽略下标
 * @throws SQLException
 */
protected List<PKValue> _saveBatchWithAutoGeneratedKeys(Connection conn,List<? extends Object> entities,int tableIndex) throws SQLException {
  List<PKValue> pks=Lists.newArrayList();
  Statement st=null;
  String sql=null;
  Class<?> clazz=null;
  for (  Object entity : entities) {
    try {
      st=conn.createStatement();
      sql=SQLBuilder.getInsert(entity,tableIndex);
      st.execute(sql,Statement.RETURN_GENERATED_KEYS);
      clazz=entity.getClass();
      if (!entityMetaManager.isUnionKey(clazz)) {
        ResultSet rs=st.getGeneratedKeys();
        PKName pkName=entityMetaManager.getNotUnionPkName(clazz);
        Field f=BeansUtil.getField(clazz,pkName.getValue());
        Object incrPK=null;
        if (rs.next()) {
          incrPK=rs.getObject(1);
          if (f.getType() == Integer.TYPE || f.getType() == Integer.class) {
            BeansUtil.setProperty(entity,pkName.getValue(),((Long)incrPK).intValue());
            pks.add(PKValue.valueOf(((Long)incrPK).intValue()));
          }
 else {
            BeansUtil.setProperty(entity,pkName.getValue(),incrPK);
            pks.add(PKValue.valueOf(incrPK));
          }
        }
      }
    }
  finally {
      JdbcUtil.close(st);
    }
  }
  return pks;
}

Fixed version (ground truth):
/** 
 * 执行保存数据操作.
 * @param conn 数据库连接
 * @param entities 需要被保存的数据
 * @param tableIndex 分片表下标. 当-1时忽略下标
 * @throws SQLException
 */
protected List<PKValue> _saveBatchWithAutoGeneratedKeys(Connection conn,List<? extends Object> entities,int tableIndex) throws SQLException {
  List<PKValue> pks=Lists.newArrayList();
  Statement st=null;
  String sql=null;
  Class<?> clazz=null;
  for (  Object entity : entities) {
    try {
      st=conn.createStatement();
      sql=SQLBuilder.getInsert(entity,tableIndex);
      st.execute(sql,Statement.RETURN_GENERATED_KEYS);
      clazz=entity.getClass();
      if (!entityMetaManager.isUnionKey(clazz)) {
        DBTablePK dbTablePK=entityMetaManager.getNotUnionPrimaryKey(clazz);
        if (dbTablePK.isAutoIncrement()) {
          ResultSet rs=st.getGeneratedKeys();
          Field f=BeansUtil.getField(clazz,dbTablePK.getField());
          Object incrPK=null;
          if (rs.next()) {
            incrPK=rs.getObject(1);
            if (f.getType() == Integer.TYPE || f.getType() == Integer.class) {
              BeansUtil.setProperty(entity,dbTablePK.getField(),((Long)incrPK).intValue());
              pks.add(PKValue.valueOf(((Long)incrPK).intValue()));
            }
 else {
              BeansUtil.setProperty(entity,dbTablePK.getField(),incrPK);
              pks.add(PKValue.valueOf(incrPK));
            }
          }
        }
 else {
          pks.add(PKValue.valueOf(BeansUtil.getProperty(entity,dbTablePK.getField())));
        }
      }
    }
  finally {
      JdbcUtil.close(st);
    }
  }
  return pks;
}
Program: 90440
Project: 90440
Buggy source:
public static PinusClient getPinusClient(){
  PinusClient pinusClient=new DefaultPinusClient();
  pinusClient.setScanPackage("String_Node_Str");
  try {
    pinusClient.init();
  }
 catch (  LoadConfigException e) {
    throw new RuntimeException(e);
  }
  return pinusClient;
}

Fixed version (ground truth):
public static PinusClient getPinusClient(){
  PinusClient pinusClient=new DefaultPinusClient();
  pinusClient.setScanPackage("String_Node_Str");
  pinusClient.setSyncAction(EnumSyncAction.UPDATE);
  try {
    pinusClient.init();
  }
 catch (  LoadConfigException e) {
    throw new RuntimeException(e);
  }
  return pinusClient;
}
Program: 90441
Project: 90441
Buggy source:
@Test public void testSave() throws Exception {
  TestGlobalEntity globalEntity=createGlobalEntity();
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  TestEntity shardingEntity=createEntity();
  pinusClient.save(globalEntity);
  System.out.println(globalEntity.getId());
  pinusClient.save(globalUKEntity);
  System.out.println(globalUKEntity);
  pinusClient.save(shardingEntity);
  System.out.println(shardingEntity.getId());
}

Fixed version (ground truth):
@Test public void testSave() throws Exception {
  TestGlobalEntity globalEntity=createGlobalEntity();
  globalEntity.setId(pinusClient.genClusterUniqueLongId("String_Node_Str"));
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  TestEntity shardingEntity=createEntity();
  shardingEntity.setId(pinusClient.genClusterUniqueLongId("String_Node_Str"));
  pinusClient.save(globalEntity);
  System.out.println(globalEntity.getId());
  pinusClient.save(globalUKEntity);
  System.out.println(globalUKEntity);
  pinusClient.save(shardingEntity);
  System.out.println(shardingEntity.getId());
}
Program: 90442
Project: 90442
Buggy source:
@Test public void testSave(){
  TestEntity entity=createEntity();
  TestGlobalEntity globalEntity=createGlobalEntity();
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  globalUKEntity.setId("String_Node_Str");
  globalUKEntity.setIndex("String_Node_Str");
  try {
    storageClient.beginTransaction();
    storageClient.save(entity);
    storageClient.globalSave(globalEntity);
    storageClient.globalSave(globalUKEntity);
    storageClient.commit();
  }
 catch (  Exception e) {
    e.printStackTrace();
    storageClient.rollback();
  }
}

Fixed version (ground truth):
@Test public void testSave(){
  TestEntity entity=createEntity();
  TestGlobalEntity globalEntity=createGlobalEntity();
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  globalUKEntity.setId("String_Node_Str");
  try {
    storageClient.beginTransaction();
    storageClient.globalSave(globalEntity);
    storageClient.commit();
  }
 catch (  Exception e) {
    e.printStackTrace();
    storageClient.rollback();
  }
}
Program: 90443
Project: 90443
Buggy source:
@Override public List<IDBResource> getAllSlaveShardingDBResource(Class<?> clazz,EnumDBMasterSlave masterSlave) throws SQLException, DBClusterException, SystemException {
  List<IDBResource> dbResources=new ArrayList<IDBResource>();
  int tableNum=entityMetaManager.getTableNum(clazz);
  if (tableNum == 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  String clusterName=entityMetaManager.getClusterName(clazz);
  String tableName=entityMetaManager.getTableName(clazz);
  ITransaction tx=(ITransaction)txManager.getTransaction();
  IDBResource dbResource=null;
  DBClusterInfo dbClusterInfo=this.getDBClusterInfo(clusterName);
  for (  DBRegionInfo region : dbClusterInfo.getDbRegions()) {
    List<DBInfo> slaveDBInfos=null;
    if (EnumDBMasterSlave.AUTO == masterSlave) {
      slaveDBInfos=region.getSlaveDBInfos().get(r.nextInt(region.getSlaveDBInfos().size() - 1));
    }
 else {
      slaveDBInfos=region.getSlaveDBInfos().get(masterSlave.getValue());
    }
    if (slaveDBInfos == null || slaveDBInfos.isEmpty()) {
      throw new DBClusterException("String_Node_Str" + clusterName);
    }
    for (    DBInfo dbInfo : slaveDBInfos) {
      for (int tableIndex=0; tableIndex < tableNum; tableIndex++) {
        dbResource=ShardingDBResource.valueOf(tx,dbInfo,region,tableName,tableIndex);
        dbResources.add(dbResource);
      }
    }
  }
  return dbResources;
}

Fixed version (ground truth):
@Override public List<IDBResource> getAllSlaveShardingDBResource(Class<?> clazz,EnumDBMasterSlave masterSlave) throws SQLException, DBClusterException, SystemException {
  List<IDBResource> dbResources=new ArrayList<IDBResource>();
  int tableNum=entityMetaManager.getTableNum(clazz);
  if (tableNum == 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  String clusterName=entityMetaManager.getClusterName(clazz);
  String tableName=entityMetaManager.getTableName(clazz);
  ITransaction tx=(ITransaction)txManager.getTransaction();
  IDBResource dbResource=null;
  DBClusterInfo dbClusterInfo=this.getDBClusterInfo(clusterName);
  for (  DBRegionInfo region : dbClusterInfo.getDbRegions()) {
    List<DBInfo> slaveDBInfos=null;
    if (EnumDBMasterSlave.AUTO == masterSlave) {
      slaveDBInfos=region.getSlaveDBInfos().get(r.nextInt(region.getSlaveDBInfos().size()));
    }
 else {
      slaveDBInfos=region.getSlaveDBInfos().get(masterSlave.getValue());
    }
    if (slaveDBInfos == null || slaveDBInfos.isEmpty()) {
      throw new DBClusterException("String_Node_Str" + clusterName);
    }
    for (    DBInfo dbInfo : slaveDBInfos) {
      for (int tableIndex=0; tableIndex < tableNum; tableIndex++) {
        dbResource=ShardingDBResource.valueOf(tx,dbInfo,region,tableName,tableIndex);
        dbResources.add(dbResource);
      }
    }
  }
  return dbResources;
}
Program: 90445
Project: 90445
Buggy source:
@Override public PKValue save(Object entity,IShardingKey<?> shardingKey){
  PKValue[] pkValues=saveBatch(Lists.newArrayList(entity),shardingKey,true);
  if (pkValues != null && pkValues.length > 1) {
    return pkValues[0];
  }
  return null;
}

Fixed version (ground truth):
@Override public PKValue save(Object entity,IShardingKey<?> shardingKey){
  PKValue[] pkValues=saveBatch(Lists.newArrayList(entity),shardingKey,true);
  if (pkValues != null && pkValues.length > 0) {
    return pkValues[0];
  }
  return null;
}
Program: 90448
Project: 90448
Buggy source:
@Override public void save(Object entity){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    CheckUtil.checkShardingEntity(entity);
    String clusterName=entityMetaManager.getClusterName(clazz);
    Object shardingKey=entityMetaManager.getShardingValue(entity);
    IShardingKey<Object> sk=new ShardingKey<Object>(clusterName,shardingKey);
    CheckUtil.checkShardingKey(sk);
    this.shardingUpdater.save(entity,sk);
  }
 else {
    CheckUtil.checkGlobalEntity(entity);
    String clusterName=entityMetaManager.getClusterName(entity.getClass());
    CheckUtil.checkClusterName(clusterName);
    this.globalUpdater.save(entity,clusterName);
  }
}

Fixed version (ground truth):
@Override public void save(Object entity){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    CheckUtil.checkShardingEntity(entity);
    IShardingKey<?> sk=entityMetaManager.getShardingKey(entity);
    CheckUtil.checkShardingKey(sk);
    this.shardingUpdater.save(entity,sk);
  }
 else {
    CheckUtil.checkGlobalEntity(entity);
    String clusterName=entityMetaManager.getClusterName(entity.getClass());
    CheckUtil.checkClusterName(clusterName);
    this.globalUpdater.save(entity,clusterName);
  }
}
Program: 90449
Project: 90449
Buggy source:
@Override public void update(Object entity){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    CheckUtil.checkShardingEntity(entity);
    String clusterName=entityMetaManager.getClusterName(entity.getClass());
    Object shardingKey=entityMetaManager.getShardingValue(entity);
    IShardingKey<Object> sk=new ShardingKey<Object>(clusterName,shardingKey);
    CheckUtil.checkShardingKey(sk);
    this.shardingUpdater.update(entity,sk);
  }
 else {
    CheckUtil.checkGlobalEntity(entity);
    String clusterName=entityMetaManager.getClusterName(entity.getClass());
    CheckUtil.checkClusterName(clusterName);
    this.globalUpdater.update(entity,clusterName);
  }
}

Fixed version (ground truth):
@Override public void update(Object entity){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    CheckUtil.checkShardingEntity(entity);
    IShardingKey<?> sk=entityMetaManager.getShardingKey(entity);
    CheckUtil.checkShardingKey(sk);
    this.shardingUpdater.update(entity,sk);
  }
 else {
    CheckUtil.checkGlobalEntity(entity);
    String clusterName=entityMetaManager.getClusterName(entity.getClass());
    CheckUtil.checkClusterName(clusterName);
    this.globalUpdater.update(entity,clusterName);
  }
}
Program: 90451
Project: 90451
Buggy source:
@Override public void load(Object entity,boolean useCache,EnumDBMasterSlave masterSlave){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityPK entityPk=entityMetaManager.getEntityPK(entity);
  List<?> resultList=null;
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    resultList=this.shardingQuery.findByPkList(Lists.newArrayList(entityPk),clazz,useCache,masterSlave);
  }
 else {
    resultList=this.globalQuery.findByPkList(Lists.newArrayList(entityPk),clazz,useCache,masterSlave);
  }
  if (resultList.isEmpty()) {
    throw new DBOperationException("String_Node_Str" + entityPk);
  }
  if (resultList.size() > 1) {
    throw new DBOperationException("String_Node_Str");
  }
  try {
    BeansUtil.copyProperties(resultList.get(0),entity);
  }
 catch (  Exception e) {
    throw new DBOperationException(e);
  }
}

Fixed version (ground truth):
@Override public void load(Object entity,boolean useCache,EnumDBMasterSlave masterSlave){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityPK entityPk=entityMetaManager.getEntityPK(entity);
  Object loadEntity=null;
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    IShardingKey<?> shardingKey=entityMetaManager.getShardingKey(entity);
    loadEntity=this.shardingQuery.findByPk(entityPk,shardingKey,clazz,useCache,masterSlave);
  }
 else {
    loadEntity=this.globalQuery.findByPk(entityPk,clazz,useCache,masterSlave);
  }
  if (loadEntity == null) {
    throw new DBOperationException("String_Node_Str" + entityPk);
  }
  try {
    BeansUtil.copyProperties(loadEntity,entity);
  }
 catch (  Exception e) {
    throw new DBOperationException(e);
  }
}
Program: 90453
Project: 90453
Buggy source:
/** 
 * 如果存在则更新，否则保存.
 */
public void saveOrUpdate(){
  Class<?> clazz=this.getClass();
  PinusClient pinusClient=DefaultPinusClient.instance;
  EntityPK entityPK=entityMetaManager.getEntityPK(this);
  IQuery<?> query=pinusClient.createQuery(clazz);
  List<Condition> orCond=Lists.newArrayList();
  PKName[] pkNames=entityPK.getPkNames();
  PKValue[] pkValues=entityPK.getPkValues();
  for (int i=0; i < pkNames.length; i++) {
    orCond.add(Condition.eq(pkNames[i].getValue(),pkValues[i].getValue()));
  }
  query.and(Condition.or(orCond.toArray(new Condition[orCond.size()])));
  if (entityMetaManager.isShardingEntity(clazz)) {
    String clusterName=entityMetaManager.getClusterName(clazz);
    Object shardingValue=entityMetaManager.getShardingValue(this);
    IShardingKey<Object> sk=new ShardingKey<Object>(clusterName,shardingValue);
    query.setShardingKey(sk);
  }
  Object obj=query.load();
  if (obj != null) {
    update();
  }
 else {
    save();
  }
}

Fixed version (ground truth):
/** 
 * 如果存在则更新，否则保存.
 */
public void saveOrUpdate(){
  Class<?> clazz=this.getClass();
  PinusClient pinusClient=DefaultPinusClient.instance;
  EntityPK entityPK=entityMetaManager.getEntityPK(this);
  IQuery<?> query=pinusClient.createQuery(clazz);
  List<Condition> orCond=Lists.newArrayList();
  PKName[] pkNames=entityPK.getPkNames();
  PKValue[] pkValues=entityPK.getPkValues();
  for (int i=0; i < pkNames.length; i++) {
    orCond.add(Condition.eq(pkNames[i].getValue(),pkValues[i].getValue()));
  }
  query.and(Condition.or(orCond.toArray(new Condition[orCond.size()])));
  if (entityMetaManager.isShardingEntity(clazz)) {
    IShardingKey<?> sk=entityMetaManager.getShardingKey(this);
    query.setShardingKey(sk);
  }
  Object obj=query.load();
  if (obj != null) {
    update();
  }
 else {
    save();
  }
}
Program: 90454
Project: 90454
Buggy source:
private PKValue(Object pkValue){
  this.pkValue=pkValue;
}

Fixed version (ground truth):
private PKValue(Object value){
  this.value=value;
}
Program: 90455
Project: 90455
Buggy source:
public Number getValueAsNumber(){
  if (this.pkValue instanceof Number) {
    return (Number)this.pkValue;
  }
 else {
    throw new ClassCastException("String_Node_Str");
  }
}

Fixed version (ground truth):
public Number getValueAsNumber(){
  if (this.value instanceof Number) {
    return (Number)this.value;
  }
 else {
    throw new ClassCastException("String_Node_Str");
  }
}
Program: 90456
Project: 90456
Buggy source:
public int getValueAsInt(){
  if (this.pkValue instanceof Number) {
    return ((Number)this.pkValue).intValue();
  }
 else {
    throw new ClassCastException("String_Node_Str");
  }
}

Fixed version (ground truth):
public int getValueAsInt(){
  if (this.value instanceof Number) {
    return ((Number)this.value).intValue();
  }
 else {
    throw new ClassCastException("String_Node_Str");
  }
}
Program: 90457
Project: 90457
Buggy source:
public static PKValue valueOf(Object pkValue){
  PKValue pk=new PKValue(pkValue);
  return pk;
}

Fixed version (ground truth):
public static PKValue valueOf(Object value){
  PKValue pk=new PKValue(value);
  return pk;
}
Program: 90458
Project: 90458
Buggy source:
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((pkValue == null) ? 0 : pkValue.hashCode());
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((value == null) ? 0 : value.hashCode());
  return result;
}
Program: 90459
Project: 90459
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  PKValue other=(PKValue)obj;
  if (pkValue == null) {
    if (other.pkValue != null)     return false;
  }
 else   if (!pkValue.equals(other.pkValue))   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  PKValue other=(PKValue)obj;
  if (value == null) {
    if (other.value != null)     return false;
  }
 else   if (!value.equals(other.value))   return false;
  return true;
}
Program: 90460
Project: 90460
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + pkValue + "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + value + "String_Node_Str";
}
Program: 90461
Project: 90461
Buggy source:
public String getValueAsString(){
  return this.pkValue.toString();
}

Fixed version (ground truth):
public String getValueAsString(){
  return this.value.toString();
}
Program: 90462
Project: 90462
Buggy source:
public long getValueAsLong(){
  if (this.pkValue instanceof Number) {
    return ((Number)this.pkValue).longValue();
  }
 else {
    throw new ClassCastException("String_Node_Str");
  }
}

Fixed version (ground truth):
public long getValueAsLong(){
  if (this.value instanceof Number) {
    return ((Number)this.value).longValue();
  }
 else {
    throw new ClassCastException("String_Node_Str");
  }
}
Program: 90464
Project: 90464
Buggy source:
/** 
 * 拼装select sql. SELECT field... FROM tableName WHERE pk = ?
 * @param pk 主键
 * @param clazz 数据对象class
 * @param tableIndex 表下标
 * @return sql语句
 */
public static String buildSelectByPk(EntityPK pk,Class<?> clazz,int tableIndex) throws SQLException {
  Field[] fields=ReflectUtil.getFields(clazz);
  String tableName=ReflectUtil.getTableName(clazz,tableIndex);
  StringBuilder whereSql=new StringBuilder();
  for (int i=0; i < pk.getPkNames().length; i++) {
    whereSql.append(pk.getPkNames()[i].getValue()).append("String_Node_Str").append(pk.getPkValues()[i].getValueAsString());
    whereSql.append("String_Node_Str");
  }
  whereSql.delete(whereSql.length() - 5,whereSql.length());
  StringBuilder SQL=new StringBuilder("String_Node_Str");
  for (  Field field : fields) {
    SQL.append(ReflectUtil.getFieldName(field)).append("String_Node_Str");
  }
  SQL.deleteCharAt(SQL.length() - 1);
  SQL.append("String_Node_Str").append(tableName);
  SQL.append("String_Node_Str").append(whereSql.toString());
  debugSQL(SQL.toString());
  return SQL.toString();
}

Fixed version (ground truth):
/** 
 * 拼装select sql. SELECT field... FROM tableName WHERE pk = ?
 * @param pk 主键
 * @param clazz 数据对象class
 * @param tableIndex 表下标
 * @return sql语句
 */
public static String buildSelectByPk(EntityPK pk,Class<?> clazz,int tableIndex) throws SQLException {
  Field[] fields=ReflectUtil.getFields(clazz);
  String tableName=ReflectUtil.getTableName(clazz,tableIndex);
  StringBuilder whereSql=new StringBuilder();
  for (int i=0; i < pk.getPkNames().length; i++) {
    whereSql.append(pk.getPkNames()[i].getValue()).append("String_Node_Str").append(formatValue(pk.getPkValues()[i].getValue()));
    whereSql.append("String_Node_Str");
  }
  whereSql.delete(whereSql.length() - 5,whereSql.length());
  StringBuilder SQL=new StringBuilder("String_Node_Str");
  for (  Field field : fields) {
    SQL.append(ReflectUtil.getFieldName(field)).append("String_Node_Str");
  }
  SQL.deleteCharAt(SQL.length() - 1);
  SQL.append("String_Node_Str").append(tableName);
  SQL.append("String_Node_Str").append(whereSql.toString());
  debugSQL(SQL.toString());
  return SQL.toString();
}
Program: 90465
Project: 90465
Buggy source:
/** 
 * 拼装select sql. SELECT field, field FROM tableName WHERE pk in (?, ?, ?)
 * @param clazz 数据对象
 * @param tableIndex 表下标
 * @param pks 主键
 * @param query 保证in顺序
 * @return sql语句
 * @throws SQLException
 */
public static String buildSelectByPks(EntityPK[] pks,Class<?> clazz,int tableIndex) throws SQLException {
  Field[] fields=ReflectUtil.getFields(clazz);
  String tableName=ReflectUtil.getTableName(clazz,tableIndex);
  StringBuilder whereSql=new StringBuilder();
  for (  EntityPK pk : pks) {
    whereSql.append("String_Node_Str");
    for (int i=0; i < pk.getPkNames().length; i++) {
      whereSql.append(pk.getPkNames()[i].getValue()).append("String_Node_Str").append(pk.getPkValues()[i].getValueAsString());
      whereSql.append("String_Node_Str");
    }
    whereSql.delete(whereSql.length() - 5,whereSql.length());
    whereSql.append("String_Node_Str");
    whereSql.append("String_Node_Str");
  }
  whereSql.delete(whereSql.length() - 4,whereSql.length());
  StringBuilder SQL=new StringBuilder("String_Node_Str");
  for (  Field field : fields) {
    SQL.append(ReflectUtil.getFieldName(field)).append("String_Node_Str");
  }
  SQL.deleteCharAt(SQL.length() - 1);
  SQL.append("String_Node_Str").append(tableName);
  SQL.append("String_Node_Str").append(whereSql.toString());
  debugSQL(SQL.toString());
  return SQL.toString();
}

Fixed version (ground truth):
/** 
 * 拼装select sql. SELECT field, field FROM tableName WHERE pk in (?, ?, ?)
 * @param clazz 数据对象
 * @param tableIndex 表下标
 * @param pks 主键
 * @param query 保证in顺序
 * @return sql语句
 * @throws SQLException
 */
public static String buildSelectByPks(EntityPK[] pks,Class<?> clazz,int tableIndex) throws SQLException {
  Field[] fields=ReflectUtil.getFields(clazz);
  String tableName=ReflectUtil.getTableName(clazz,tableIndex);
  StringBuilder whereSql=new StringBuilder();
  for (  EntityPK pk : pks) {
    whereSql.append("String_Node_Str");
    for (int i=0; i < pk.getPkNames().length; i++) {
      whereSql.append(pk.getPkNames()[i].getValue()).append("String_Node_Str").append(formatValue(pk.getPkValues()[i].getValue()));
      whereSql.append("String_Node_Str");
    }
    whereSql.delete(whereSql.length() - 5,whereSql.length());
    whereSql.append("String_Node_Str");
    whereSql.append("String_Node_Str");
  }
  whereSql.delete(whereSql.length() - 4,whereSql.length());
  StringBuilder SQL=new StringBuilder("String_Node_Str");
  for (  Field field : fields) {
    SQL.append(ReflectUtil.getFieldName(field)).append("String_Node_Str");
  }
  SQL.deleteCharAt(SQL.length() - 1);
  SQL.append("String_Node_Str").append(tableName);
  SQL.append("String_Node_Str").append(whereSql.toString());
  debugSQL(SQL.toString());
  return SQL.toString();
}
Program: 90466
Project: 90466
Buggy source:
public static TestGlobalUnionKeyEntity createGlobalUnionKeyEntity(){
  TestGlobalUnionKeyEntity testEntity=new TestGlobalUnionKeyEntity();
  testEntity.setId(r.nextInt());
  testEntity.setTestBool(r.nextBoolean());
  testEntity.setoTestBool(r.nextBoolean());
  testEntity.setTestByte((byte)255);
  testEntity.setoTestByte((byte)255);
  testEntity.setTestChar('b');
  testEntity.setoTestChar('b');
  testEntity.setTestDate(new Date());
  testEntity.setTestDouble(1.0);
  testEntity.setoTestDouble(1.0);
  testEntity.setTestFloat(2.0f);
  testEntity.setoTestFloat(2.0f);
  testEntity.setTestInt(5);
  testEntity.setoTestInt(5);
  testEntity.setTestLong(6l);
  testEntity.setoTestLong(6l);
  testEntity.setTestShort((short)7);
  testEntity.setoTestShort((short)7);
  testEntity.setTestString(getContent(r.nextInt(100)));
  testEntity.setTestTime(new Timestamp(System.currentTimeMillis()));
  return testEntity;
}

Fixed version (ground truth):
public static TestGlobalUnionKeyEntity createGlobalUnionKeyEntity(){
  TestGlobalUnionKeyEntity testEntity=new TestGlobalUnionKeyEntity();
  testEntity.setTestBool(r.nextBoolean());
  testEntity.setoTestBool(r.nextBoolean());
  testEntity.setTestByte((byte)255);
  testEntity.setoTestByte((byte)255);
  testEntity.setTestChar('b');
  testEntity.setoTestChar('b');
  testEntity.setTestDate(new Date());
  testEntity.setTestDouble(1.0);
  testEntity.setoTestDouble(1.0);
  testEntity.setTestFloat(2.0f);
  testEntity.setoTestFloat(2.0f);
  testEntity.setTestInt(5);
  testEntity.setoTestInt(5);
  testEntity.setTestLong(6l);
  testEntity.setoTestLong(6l);
  testEntity.setTestShort((short)7);
  testEntity.setoTestShort((short)7);
  testEntity.setTestString(getContent(r.nextInt(100)));
  testEntity.setTestTime(new Timestamp(System.currentTimeMillis()));
  return testEntity;
}
Program: 90467
Project: 90467
Buggy source:
@Test public void testSave(){
  TestEntity entity=createEntity();
  TestGlobalEntity globalEntity=createGlobalEntity();
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  try {
    storageClient.beginTransaction();
    storageClient.save(entity);
    storageClient.globalSave(globalEntity);
    storageClient.globalSave(globalUKEntity);
    storageClient.commit();
  }
 catch (  Exception e) {
    e.printStackTrace();
    storageClient.rollback();
  }
}

Fixed version (ground truth):
@Test public void testSave(){
  TestEntity entity=createEntity();
  TestGlobalEntity globalEntity=createGlobalEntity();
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  globalUKEntity.setId("String_Node_Str");
  try {
    storageClient.beginTransaction();
    storageClient.save(entity);
    storageClient.globalSave(globalEntity);
    storageClient.globalSave(globalUKEntity);
    storageClient.commit();
  }
 catch (  Exception e) {
    e.printStackTrace();
    storageClient.rollback();
  }
}
Program: 90468
Project: 90468
Buggy source:
@Test public void testUpdate(){
  try {
    storageClient.beginTransaction();
    TestGlobalEntity globalEntity=storageClient.findByPk(14,TestGlobalEntity.class);
    storageClient.globalUpdate(globalEntity);
    IQuery query=storageClient.createQuery();
    query.add(Condition.eq("String_Node_Str",1349897939));
    query.add(Condition.eq("String_Node_Str",(byte)-1));
    TestGlobalUnionKeyEntity globalUnionKeyEntity=storageClient.findOneByQuery(query,TestGlobalUnionKeyEntity.class);
    storageClient.globalUpdate(globalUnionKeyEntity);
    storageClient.commit();
  }
 catch (  Exception e) {
    e.printStackTrace();
    storageClient.rollback();
  }
}

Fixed version (ground truth):
@Test public void testUpdate(){
  try {
    storageClient.beginTransaction();
    IQuery query=storageClient.createQuery();
    query.add(Condition.eq("String_Node_Str","String_Node_Str"));
    query.add(Condition.eq("String_Node_Str",(byte)-1));
    TestGlobalUnionKeyEntity globalUnionKeyEntity=storageClient.findOneByQuery(query,TestGlobalUnionKeyEntity.class);
    storageClient.globalUpdate(globalUnionKeyEntity);
    storageClient.commit();
  }
 catch (  Exception e) {
    e.printStackTrace();
    storageClient.rollback();
  }
}
Program: 90469
Project: 90469
Buggy source:
public long getId(){
  return id;
}

Fixed version (ground truth):
public String getId(){
  return id;
}
Program: 90470
Project: 90470
Buggy source:
public void setId(long id){
  this.id=id;
}

Fixed version (ground truth):
public void setId(String id){
  this.id=id;
}
Program: 90471
Project: 90471
Buggy source:
private List<Object> _get(List<String> keys){
  List<Object> datas=new ArrayList<Object>();
  try {
    Object value=null;
    for (    String key : keys) {
      value=_get(key);
      if (value != null)       datas.add(value);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str" + e.getMessage());
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + keys + "String_Node_Str"+ datas.size());
  }
  return datas;
}

Fixed version (ground truth):
private List<Object> _get(List<String> keys){
  List<Object> datas=new ArrayList<Object>();
  try {
    Object value=null;
    for (    String key : keys) {
      value=_get(key);
      if (value != null)       datas.add(value);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str" + e.getMessage());
  }
  return datas;
}
Program: 90472
Project: 90472
Buggy source:
@Override public void load(Object entity,boolean useCache,EnumDBMasterSlave masterSlave){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Object loadedEntity=null;
  EntityPK entityPk=entityMetaManager.getEntityPK(entity);
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    loadedEntity=this.shardingQuery.findByPkList(Lists.newArrayList(entityPk),clazz,useCache,masterSlave);
  }
 else {
    loadedEntity=this.globalQuery.findByPkList(Lists.newArrayList(entityPk),clazz,useCache,masterSlave);
  }
  if (loadedEntity == null) {
    throw new DBOperationException("String_Node_Str" + entityPk);
  }
  try {
    BeansUtil.copyProperties(loadedEntity,entity);
  }
 catch (  Exception e) {
    throw new DBOperationException(e);
  }
}

Fixed version (ground truth):
@Override public void load(Object entity,boolean useCache,EnumDBMasterSlave masterSlave){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityPK entityPk=entityMetaManager.getEntityPK(entity);
  List<?> resultList=null;
  Class<?> clazz=entity.getClass();
  if (entityMetaManager.isShardingEntity(clazz)) {
    resultList=this.shardingQuery.findByPkList(Lists.newArrayList(entityPk),clazz,useCache,masterSlave);
  }
 else {
    resultList=this.globalQuery.findByPkList(Lists.newArrayList(entityPk),clazz,useCache,masterSlave);
  }
  if (resultList.isEmpty()) {
    throw new DBOperationException("String_Node_Str" + entityPk);
  }
  if (resultList.size() > 1) {
    throw new DBOperationException("String_Node_Str");
  }
  try {
    BeansUtil.copyProperties(resultList.get(0),entity);
  }
 catch (  Exception e) {
    throw new DBOperationException(e);
  }
}
Program: 90473
Project: 90473
Buggy source:
/** 
 * 将当前Query查询转换为PK查询，提高缓存的命中率.
 * @return
 */
private List<EntityPK> coverToEntityPK(){
  List<EntityPK> entityPkList=Lists.newArrayList();
  PKName[] pkNames=entityMetaManager.getPkName(this.clazz);
  if (pkNames.length != this.condList.size()) {
    return null;
  }
  boolean isMatch=true;
  Condition cond=null;
  for (int i=0; i < this.condList.size(); i++) {
    cond=this.condList.get(i);
    if (i > 0 && cond.getConditionRelation() != ConditionRelation.OR) {
      isMatch=false;
      break;
    }
    if (pkNames.length == 1 && cond.getOrCond().length == 0 && cond.getAndCond().length == 0 && cond.getOpt() == QueryOpt.EQ) {
      PKValue[] pkValues=new PKValue[]{PKValue.valueOf(cond.getValue())};
      entityPkList.add(EntityPK.valueOf(pkNames,pkValues));
    }
 else {
      isMatch=false;
      break;
    }
    if (pkNames.length > 1 && cond.getOrCond().length == 0 && cond.getAndCond().length == pkNames.length && cond.isAndCondAllEQ()) {
      PKValue[] pkValues=new PKValue[cond.getAndCond().length];
      for (int j=0; j < cond.getAndCond().length; j++) {
        pkValues[j]=PKValue.valueOf(cond.getAndCond()[j].getValue());
      }
      entityPkList.add(EntityPK.valueOf(pkNames,pkValues));
    }
 else {
      isMatch=false;
    }
  }
  if (!isMatch) {
    return null;
  }
  return entityPkList;
}

Fixed version (ground truth):
/** 
 * 将当前Query查询转换为PK查询，提高缓存的命中率.
 * @return
 */
private List<EntityPK> coverToEntityPK(){
  List<EntityPK> entityPkList=Lists.newArrayList();
  PKName[] pkNames=entityMetaManager.getPkName(this.clazz);
  if (pkNames.length != this.condList.size()) {
    return null;
  }
  boolean isMatch=true;
  Condition cond=null;
  for (int i=0; i < this.condList.size(); i++) {
    cond=this.condList.get(i);
    if (i > 0 && cond.getConditionRelation() != ConditionRelation.OR) {
      isMatch=false;
      break;
    }
    if (pkNames.length == 1 && (cond.getOrCond() == null || cond.getOrCond().length == 0) && (cond.getAndCond() == null || cond.getAndCond().length == 0) && cond.getOpt() == QueryOpt.EQ && cond.getField().equals(pkNames[0].getValue())) {
      PKValue[] pkValues=new PKValue[]{PKValue.valueOf(cond.getValue())};
      entityPkList.add(EntityPK.valueOf(pkNames,pkValues));
    }
 else {
      isMatch=false;
      break;
    }
    if (pkNames.length > 1 && (cond.getOrCond() == null || cond.getOrCond().length == 0) && cond.getAndCond() != null && cond.getAndCond().length == pkNames.length && cond.isAndCondAllEQ()) {
      PKValue[] pkValues=new PKValue[cond.getAndCond().length];
      for (int j=0; j < cond.getAndCond().length; j++) {
        if (!pkNames[j].getValue().equals(cond.getAndCond()[j].getField())) {
          isMatch=false;
          break;
        }
        pkValues[j]=PKValue.valueOf(cond.getAndCond()[j].getValue());
      }
      entityPkList.add(EntityPK.valueOf(pkNames,pkValues));
    }
 else {
      isMatch=false;
    }
  }
  if (!isMatch) {
    return null;
  }
  return entityPkList;
}
Program: 90474
Project: 90474
Buggy source:
/** 
 * 执行保存数据操作.
 * @param conn 数据库连接
 * @param entities 需要被保存的数据
 * @param tableIndex 分片表下标. 当-1时忽略下标
 */
protected List<PKValue> _saveBatch(Connection conn,List<? extends Object> entities,int tableIndex){
  List<PKValue> pks=Lists.newArrayList();
  Statement st=null;
  String sql=null;
  Class<?> clazz=null;
  for (  Object entity : entities) {
    try {
      st=conn.createStatement();
      sql=SQLBuilder.getInsert(conn,entity,tableIndex);
      st.execute(sql,Statement.RETURN_GENERATED_KEYS);
      clazz=entity.getClass();
      if (!entityMetaManager.isUnionKey(clazz)) {
        ResultSet rs=st.getGeneratedKeys();
        PKName pkName=entityMetaManager.getNotUnionPkName(clazz);
        if (rs.next()) {
          BeansUtil.setProperty(entity,pkName.getValue(),rs.getObject(1));
          pks.add(PKValue.valueOf(rs.getObject(1)));
        }
      }
    }
 catch (    SQLException e) {
      try {
        conn.rollback();
      }
 catch (      SQLException e1) {
        LOG.error(e1.getMessage());
      }
      throw new DBOperationException(e);
    }
 finally {
      JdbcUtil.close(st);
    }
  }
  return pks;
}

Fixed version (ground truth):
/** 
 * 执行保存数据操作.
 * @param conn 数据库连接
 * @param entities 需要被保存的数据
 * @param tableIndex 分片表下标. 当-1时忽略下标
 */
protected List<PKValue> _saveBatch(Connection conn,List<? extends Object> entities,int tableIndex){
  List<PKValue> pks=Lists.newArrayList();
  Statement st=null;
  String sql=null;
  Class<?> clazz=null;
  for (  Object entity : entities) {
    try {
      st=conn.createStatement();
      sql=SQLBuilder.getInsert(conn,entity,tableIndex);
      st.execute(sql,Statement.RETURN_GENERATED_KEYS);
      clazz=entity.getClass();
      if (!entityMetaManager.isUnionKey(clazz)) {
        ResultSet rs=st.getGeneratedKeys();
        PKName pkName=entityMetaManager.getNotUnionPkName(clazz);
        Field f=BeansUtil.getField(clazz,pkName.getValue());
        Object incrPK=null;
        if (rs.next()) {
          incrPK=rs.getObject(1);
          if (f.getType() == Integer.TYPE || f.getType() == Integer.class) {
            BeansUtil.setProperty(entity,pkName.getValue(),((Long)incrPK).intValue());
            pks.add(PKValue.valueOf(((Long)incrPK).intValue()));
          }
 else {
            BeansUtil.setProperty(entity,pkName.getValue(),incrPK);
            pks.add(PKValue.valueOf(incrPK));
          }
        }
      }
    }
 catch (    SQLException e) {
      try {
        conn.rollback();
      }
 catch (      SQLException e1) {
        LOG.error(e1.getMessage());
      }
      throw new DBOperationException(e);
    }
 finally {
      JdbcUtil.close(st);
    }
  }
  return pks;
}