@Test public void TestSql() throws Exception { SQL sql = SQL.valueOf("select * from testglobalentity where pk < ?", 20); List<Map<String, Object>> result = pinusClient.findBySQL(sql, CLUSTER_KLSTORAGE); for (Map<String, Object> res : result) { System.out.println(res); } }
@Override public List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz) { if (sql == null) { throw new IllegalArgumentException("param sql should not be null"); } if (clazz == null) { throw new IllegalArgumentException("param class should not be null"); } CheckUtil.checkSQL(sql); CheckUtil.checkClass(clazz); String clusterName = entityMetaManager.getClusterName(clazz); if (entityMetaManager.isShardingEntity(clazz)) { return this.shardingQuery.findBySql(sql, EnumDBMasterSlave.AUTO); } else { return this.globalQuery.findBySql(sql, clusterName, EnumDBMasterSlave.AUTO); } }
DefaultPinusClient implements PinusClient { @Override public List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz) { if (sql == null) { throw new IllegalArgumentException("param sql should not be null"); } if (clazz == null) { throw new IllegalArgumentException("param class should not be null"); } CheckUtil.checkSQL(sql); CheckUtil.checkClass(clazz); String clusterName = entityMetaManager.getClusterName(clazz); if (entityMetaManager.isShardingEntity(clazz)) { return this.shardingQuery.findBySql(sql, EnumDBMasterSlave.AUTO); } else { return this.globalQuery.findBySql(sql, clusterName, EnumDBMasterSlave.AUTO); } } }
DefaultPinusClient implements PinusClient { @Override public List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz) { if (sql == null) { throw new IllegalArgumentException("param sql should not be null"); } if (clazz == null) { throw new IllegalArgumentException("param class should not be null"); } CheckUtil.checkSQL(sql); CheckUtil.checkClass(clazz); String clusterName = entityMetaManager.getClusterName(clazz); if (entityMetaManager.isShardingEntity(clazz)) { return this.shardingQuery.findBySql(sql, EnumDBMasterSlave.AUTO); } else { return this.globalQuery.findBySql(sql, clusterName, EnumDBMasterSlave.AUTO); } }  }
DefaultPinusClient implements PinusClient { @Override public List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz) { if (sql == null) { throw new IllegalArgumentException("param sql should not be null"); } if (clazz == null) { throw new IllegalArgumentException("param class should not be null"); } CheckUtil.checkSQL(sql); CheckUtil.checkClass(clazz); String clusterName = entityMetaManager.getClusterName(clazz); if (entityMetaManager.isShardingEntity(clazz)) { return this.shardingQuery.findBySql(sql, EnumDBMasterSlave.AUTO); } else { return this.globalQuery.findBySql(sql, clusterName, EnumDBMasterSlave.AUTO); } }  void init(); @Override void destroy(); @Override void beginTransaction(); @Override void beginTransaction(EnumTransactionIsolationLevel txLevel); @Override void commit(); @Override void rollback(); @Override void flush(); @Override TaskFuture submit(ITask<T> task, Class<T> clazz); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override TaskFuture submit(ITask<T> task, Class<T> clazz, IQuery<T> query); @Override void save(Object entity); @Override void saveBatch(List<? extends Object> entityList); @Override void saveBatch(List<? extends Object> entityList, boolean autoGeneratedKeys); @Override void update(Object entity); @Override void updateBatch(List<? extends Object> entityList); @Override void delete(Object entity); @Override void delete(List<? extends Object> entityList); @Override void load(Object entity); @Override void load(Object entity, boolean useCache); @Override void load(Object entity, EnumDBMasterSlave masterSlave); @Override void load(Object entity, boolean useCache, EnumDBMasterSlave masterSlave); @Override IQuery<T> createQuery(Class<T> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, String clusterName); @Override IDBCluster getDBCluster(); @Override IPrimaryCache getPrimaryCache(); @Override ISecondCache getSecondCache(); @Override int genClusterUniqueIntId(String name); @Override long genClusterUniqueLongId(String name); @Override long[] genClusterUniqueLongIdBatch(String name, int batchSize); @Override int[] genClusterUniqueIntIdBatch(String name, int batchSize); @Override Lock createLock(String lockName); EnumSyncAction getSyncAction(); @Override void setSyncAction(EnumSyncAction syncAction); String getScanPackage(); @Override void setScanPackage(String scanPackage); }
DefaultPinusClient implements PinusClient { @Override public List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz) { if (sql == null) { throw new IllegalArgumentException("param sql should not be null"); } if (clazz == null) { throw new IllegalArgumentException("param class should not be null"); } CheckUtil.checkSQL(sql); CheckUtil.checkClass(clazz); String clusterName = entityMetaManager.getClusterName(clazz); if (entityMetaManager.isShardingEntity(clazz)) { return this.shardingQuery.findBySql(sql, EnumDBMasterSlave.AUTO); } else { return this.globalQuery.findBySql(sql, clusterName, EnumDBMasterSlave.AUTO); } }  void init(); @Override void destroy(); @Override void beginTransaction(); @Override void beginTransaction(EnumTransactionIsolationLevel txLevel); @Override void commit(); @Override void rollback(); @Override void flush(); @Override TaskFuture submit(ITask<T> task, Class<T> clazz); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override TaskFuture submit(ITask<T> task, Class<T> clazz, IQuery<T> query); @Override void save(Object entity); @Override void saveBatch(List<? extends Object> entityList); @Override void saveBatch(List<? extends Object> entityList, boolean autoGeneratedKeys); @Override void update(Object entity); @Override void updateBatch(List<? extends Object> entityList); @Override void delete(Object entity); @Override void delete(List<? extends Object> entityList); @Override void load(Object entity); @Override void load(Object entity, boolean useCache); @Override void load(Object entity, EnumDBMasterSlave masterSlave); @Override void load(Object entity, boolean useCache, EnumDBMasterSlave masterSlave); @Override IQuery<T> createQuery(Class<T> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, String clusterName); @Override IDBCluster getDBCluster(); @Override IPrimaryCache getPrimaryCache(); @Override ISecondCache getSecondCache(); @Override int genClusterUniqueIntId(String name); @Override long genClusterUniqueLongId(String name); @Override long[] genClusterUniqueLongIdBatch(String name, int batchSize); @Override int[] genClusterUniqueIntIdBatch(String name, int batchSize); @Override Lock createLock(String lockName); EnumSyncAction getSyncAction(); @Override void setSyncAction(EnumSyncAction syncAction); String getScanPackage(); @Override void setScanPackage(String scanPackage); static final Logger LOG; static PinusClient instance; }