use of com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper in project dal by ctripcorp.
the class PartialQueryQueryDaoTest method findFreeFirstBigger.
// Result set is bigger than entity
public FreeEntityPartialPojo findFreeFirstBigger(String name, List<Integer> cityIds, DalHints hints) throws SQLException {
DalQueryDao queryDao = new DalQueryDao(DATA_BASE);
DalDefaultJpaMapper<FreeEntityPartialPojo> freeEntityPojoRowMapper = new DalDefaultJpaMapper<>(FreeEntityPartialPojo.class);
hints = DalHints.createIfAbsent(hints);
FreeSelectSqlBuilder<FreeEntityPartialPojo> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT * FROM Person WHERE name LIKE ? and CityId in (?) ORDER BY name");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.setSensitive(i++, "name", Types.VARCHAR, name);
i = parameters.setSensitiveInParameter(i, "cityIds", Types.INTEGER, cityIds);
builder.mapWith(freeEntityPojoRowMapper).requireFirst().nullable();
return (FreeEntityPartialPojo) queryDao.query(builder, parameters, hints);
}
use of com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper in project dal by ctripcorp.
the class PartialQueryQueryDaoTest method findFreeFirstMismatch.
// Result set is not same with entity
public FreeEntityMismatchPojo findFreeFirstMismatch(String name, List<Integer> cityIds, DalHints hints) throws SQLException {
DalQueryDao queryDao = new DalQueryDao(DATA_BASE);
DalDefaultJpaMapper<FreeEntityMismatchPojo> freeEntityPojoRowMapper = new DalDefaultJpaMapper<>(FreeEntityMismatchPojo.class);
hints = DalHints.createIfAbsent(hints);
FreeSelectSqlBuilder<FreeEntityMismatchPojo> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT * FROM Person WHERE name LIKE ? and CityId in (?) ORDER BY name");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.setSensitive(i++, "name", Types.VARCHAR, name);
i = parameters.setSensitiveInParameter(i, "cityIds", Types.INTEGER, cityIds);
builder.mapWith(freeEntityPojoRowMapper).requireFirst().nullable();
return (FreeEntityMismatchPojo) queryDao.query(builder, parameters, hints);
}
use of com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper in project dal by ctripcorp.
the class PartialQueryQueryDaoTest method findFreeFirstSmaller.
// Result set is smaller than entity
public FreeEntityPartialPojo findFreeFirstSmaller(String name, List<Integer> cityIds, DalHints hints) throws SQLException {
DalQueryDao queryDao = new DalQueryDao(DATA_BASE);
DalDefaultJpaMapper<FreeEntityPartialPojo> freeEntityPojoRowMapper = new DalDefaultJpaMapper<>(FreeEntityPartialPojo.class);
hints = DalHints.createIfAbsent(hints);
FreeSelectSqlBuilder<FreeEntityPartialPojo> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT * FROM Person WHERE name LIKE ? and CityId in (?) ORDER BY name");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.setSensitive(i++, "name", Types.VARCHAR, name);
i = parameters.setSensitiveInParameter(i, "cityIds", Types.INTEGER, cityIds);
builder.mapWith(freeEntityPojoRowMapper).requireFirst().nullable();
return (FreeEntityPartialPojo) queryDao.query(builder, parameters, hints.partialQuery("PeopleID", "Name", "CityID", "ProvinceID"));
}
use of com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper in project dal by ctripcorp.
the class PartialQueryQueryDaoTest method findFreeFirstSame.
//Result set is same than entity
public FreeEntityPojo findFreeFirstSame(String name, List<Integer> cityIds, DalHints hints) throws SQLException {
DalQueryDao queryDao = new DalQueryDao(DATA_BASE);
DalDefaultJpaMapper<FreeEntityPojo> freeEntityPojoRowMapper = new DalDefaultJpaMapper<>(FreeEntityPojo.class);
hints = DalHints.createIfAbsent(hints);
FreeSelectSqlBuilder<FreeEntityPojo> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT * FROM Person WHERE name LIKE ? and CityId in (?) ORDER BY name");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.setSensitive(i++, "name", Types.VARCHAR, name);
i = parameters.setSensitiveInParameter(i, "cityIds", Types.INTEGER, cityIds);
builder.mapWith(freeEntityPojoRowMapper).requireFirst().nullable();
return (FreeEntityPojo) queryDao.query(builder, parameters, hints);
}
Aggregations