本文整理汇总了Java中com.mysema.query.sql.SQLQuery.from方法的典型用法代码示例。如果您正苦于以下问题:Java SQLQuery.from方法的具体用法?Java SQLQuery.from怎么用?Java SQLQuery.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysema.query.sql.SQLQuery
的用法示例。
在下文中一共展示了SQLQuery.from方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QAuthor
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec0102_Beanとして取出す_QBean() {
/* 抽出条件を組み立てる。 */
QAuthor a = new QAuthor("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Author> list = queryDslJdbcOperations.query(query, new QBean<Author>(Author.class, a.all()));
/* クエリの結果を表示する。 */
for (Author entity : list) {
Long valId = entity.getId();
String valLoginId = entity.getLoginId();
String valName = entity.getName();
LocalDateTime valUpdatedAt = entity.getUpdatedAt();
LocalDateTime valCreatedAt = entity.getCreatedAt();
Integer valLockVersion = entity.getLockVersion();
Integer valDeletedFlg = entity.getDeletedFlg();
out.println(format(
"{0}: loginId={1}, name={2}, updatedAt={3}, createdAt={4}, lockVersion={5}, deletedFlg={6}", valId,
valLoginId, valName, valUpdatedAt, valCreatedAt, valLockVersion, valDeletedFlg));
}
}
示例2: sec0502_HAVING
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec0502_HAVING() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
query.having(a.id.count().gt(1), a.postedAt.max().lt(new LocalDateTime(2015, 2, 1, 0, 0)));
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}
示例3: sec0503_ORDERBY
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec0503_ORDERBY() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
query.orderBy(a.id.count().asc());
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}
示例4: QAuthor
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec020104_カラムにエイリアスを付与する() {
QAuthor a = new QAuthor("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
List<Tuple> list = queryDslJdbcOperations.query(
query,
new QTuple(a.id.as("alias1"), a.loginId.as("alias2"), a.name
.as("alias3")));
for (Tuple tuple : list) {
Long valId = tuple.get(a.id.as("alias1"));
String valLoginId = tuple.get(a.loginId.as("alias2"));
String valName = tuple.get(a.name.as("alias3"));
out.println(format("{0}: loginId={1}, name={2}", valId, valLoginId,
valName));
assertThat(tuple.get(a.id), is(nullValue()));
assertThat(tuple.get(a.loginId), is(nullValue()));
assertThat(tuple.get(a.name), is(nullValue()));
}
}
示例5: QTodo
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec020408_カラムに対する関数適用_集約関数() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(
a.postedBy, a.id.count(), a.id.sum(), a.postedAt.min(),
a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format(
"{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}",
valPostedBy, valCount, valSum, valMinPostedAt,
valMaxPostedAt));
}
}
示例6: execute
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
public List<T> execute() {
Validate.notNull(example);
final SQLQuery sqlQuery = new SQLQuery(configuration);
sqlQuery.from(pathBase);
addSpec(sqlQuery);
returnPaths.addAll(QueryExampleHelper.getReturnPath(pathBase, example));
Path<?>[] pathArray = new Path<?>[returnPaths.size()];
SQLBindings sqlBindings = sqlQuery.getSQL(returnPaths.toArray(pathArray));
String sql = sqlBindings.getSQL();
List<Object> args = sqlBindings.getBindings();
LOGGER.debug("SQL: {} \nparams: {}", sql, args);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
return jdbcTemplate.query(sql, args.toArray(), rowMapper);
}
示例7: getCodeList
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Transactional(readOnly = true)
@Override
public List<CodeEntry> getCodeList(String codeName) {
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(qcm);
query.where(qcm.name.eq(codeName), qcm.deletedFlg.eq(DeletedFlag.NOT_DELETED.code()));
query.orderBy(qcm.sortOrder.asc());
return queryDslJdbcOperations.query(query, new QBean<>(CodeEntry.class, qcm.value, qcm.label, qcm.sortOrder));
}
示例8: getNumberOfWorkday
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Override
public int getNumberOfWorkday(String name, LocalDate from, LocalDate to) {
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(h0);
query.where(h0.name.eq(name), h0.dt.between(constant(from), constant(to)), h0.deletedFlg.eq(NOT_DELETED.code()));
long count = queryDslJdbcOperations.queryForObject(query, h0.dt.count());
return Days.daysBetween(from, to).getDays() + 1 - (int) count;
}
示例9: commonClause
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
private QueryConfigurer commonClause(final QVerifyDatetime qvd) {
return new QueryConfigurer() {
@Override
public SQLQuery configure(SQLQuery query) {
query.from(qvd);
query.where(qvd.dt.goe(localDate));
return query;
}
};
}
示例10: createBaseQuery
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
private SQLQuery createBaseQuery(String numberName) {
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(nm);
query.where(nm.name.eq(numberName), nm.deletedFlg.eq(DeletedFlag.NOT_DELETED.code()));
return query;
}
示例11: commonClause
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
private QueryConfigurer commonClause(final BasicEx60Form form) {
return new QueryConfigurer() {
@Override
public SQLQuery configure(SQLQuery query) {
query.from(et1);
if (StringUtils.isNotEmpty(form.getText10())) {
query.where(et1.text10.startsWith(form.getText10()));
}
if (form.getInt64From() != null) {
query.where(et1.int64.goe(form.getInt64From()));
}
if (form.getInt64To() != null) {
query.where(et1.int64.loe(form.getInt64To()));
}
if (form.getDecimal1From() != null) {
query.where(et1.decimal1.goe(form.getDecimal1From()));
}
if (form.getDecimal1To() != null) {
query.where(et1.decimal1.loe(form.getDecimal1To()));
}
if (form.getDecimal3From() != null) {
query.where(et1.decimal3.goe(form.getDecimal3From()));
}
if (form.getDecimal3To() != null) {
query.where(et1.decimal3.loe(form.getDecimal3To()));
}
if (form.getDtFrom() != null) {
query.where(et1.dt.goe(form.getDtFrom()));
}
if (form.getDtTo() != null) {
query.where(et1.dt.loe(form.getDtTo()));
}
if (form.getTmFrom() != null) {
query.where(et1.tm.goe(form.getTmFrom()));
}
if (form.getTmTo() != null) {
query.where(et1.tm.loe(form.getTmTo()));
}
if (form.getDtmFromD() != null && form.getDtmFromT() != null) {
query.where(et1.dtm.goe(form.getDtmFromD().toLocalDateTime(form.getDtmFromT())));
}
if (form.getDtmToD() != null && form.getDtmToT() != null) {
query.where(et1.dtm.loe(form.getDtmToD().toLocalDateTime(form.getDtmToT())));
}
return query;
}
};
}
示例12: commonClause
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
private QueryConfigurer commonClause(final AppliedEx50Form form) {
return new QueryConfigurer() {
@Override
public SQLQuery configure(SQLQuery query) {
query.from(et1);
if (StringUtils.isNotEmpty(form.getText10())) {
query.where(et1.text10.startsWith(form.getText10()));
}
if (form.getInt64From() != null) {
query.where(et1.int64.goe(form.getInt64From()));
}
if (form.getInt64To() != null) {
query.where(et1.int64.loe(form.getInt64To()));
}
if (form.getDecimal1From() != null) {
query.where(et1.decimal1.goe(form.getDecimal1From()));
}
if (form.getDecimal1To() != null) {
query.where(et1.decimal1.loe(form.getDecimal1To()));
}
if (form.getDecimal3From() != null) {
query.where(et1.decimal3.goe(form.getDecimal3From()));
}
if (form.getDecimal3To() != null) {
query.where(et1.decimal3.loe(form.getDecimal3To()));
}
if (form.getDtFrom() != null) {
query.where(et1.dt.goe(form.getDtFrom()));
}
if (form.getDtTo() != null) {
query.where(et1.dt.loe(form.getDtTo()));
}
if (form.getTmFrom() != null) {
query.where(et1.tm.goe(form.getTmFrom()));
}
if (form.getTmTo() != null) {
query.where(et1.tm.loe(form.getTmTo()));
}
if (form.getDtmFromD() != null && form.getDtmFromT() != null) {
query.where(et1.dtm.goe(form.getDtmFromD().toLocalDateTime(form.getDtmFromT())));
}
if (form.getDtmToD() != null && form.getDtmToT() != null) {
query.where(et1.dtm.loe(form.getDtmToD().toLocalDateTime(form.getDtmToT())));
}
return query;
}
};
}
示例13: commonClause
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
private QueryConfigurer commonClause(final AppliedEx60Form form) {
return new QueryConfigurer() {
@Override
public SQLQuery configure(SQLQuery query) {
query.from(et1);
if (StringUtils.isNotEmpty(form.getText10())) {
query.where(et1.text10.startsWith(form.getText10()));
}
if (form.getInt64From() != null) {
query.where(et1.int64.goe(form.getInt64From()));
}
if (form.getInt64To() != null) {
query.where(et1.int64.loe(form.getInt64To()));
}
if (form.getDecimal1From() != null) {
query.where(et1.decimal1.goe(form.getDecimal1From()));
}
if (form.getDecimal1To() != null) {
query.where(et1.decimal1.loe(form.getDecimal1To()));
}
if (form.getDecimal3From() != null) {
query.where(et1.decimal3.goe(form.getDecimal3From()));
}
if (form.getDecimal3To() != null) {
query.where(et1.decimal3.loe(form.getDecimal3To()));
}
if (form.getDtFrom() != null) {
query.where(et1.dt.goe(form.getDtFrom()));
}
if (form.getDtTo() != null) {
query.where(et1.dt.loe(form.getDtTo()));
}
if (form.getTmFrom() != null) {
query.where(et1.tm.goe(form.getTmFrom()));
}
if (form.getTmTo() != null) {
query.where(et1.tm.loe(form.getTmTo()));
}
if (form.getDtmFromD() != null && form.getDtmFromT() != null) {
query.where(et1.dtm.goe(form.getDtmFromD().toLocalDateTime(form.getDtmFromT())));
}
if (form.getDtmToD() != null && form.getDtmToT() != null) {
query.where(et1.dtm.loe(form.getDtmToD().toLocalDateTime(form.getDtmToT())));
}
return query;
}
};
}
示例14: commonClause
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
private QueryConfigurer commonClause(final BasicEx50Form form) {
return new QueryConfigurer() {
@Override
public SQLQuery configure(SQLQuery query) {
query.from(et1);
if (StringUtils.isNotEmpty(form.getText10())) {
query.where(et1.text10.startsWith(form.getText10()));
}
if (form.getInt64From() != null) {
query.where(et1.int64.goe(form.getInt64From()));
}
if (form.getInt64To() != null) {
query.where(et1.int64.loe(form.getInt64To()));
}
if (form.getDecimal1From() != null) {
query.where(et1.decimal1.goe(form.getDecimal1From()));
}
if (form.getDecimal1To() != null) {
query.where(et1.decimal1.loe(form.getDecimal1To()));
}
if (form.getDecimal3From() != null) {
query.where(et1.decimal3.goe(form.getDecimal3From()));
}
if (form.getDecimal3To() != null) {
query.where(et1.decimal3.loe(form.getDecimal3To()));
}
if (form.getDtFrom() != null) {
query.where(et1.dt.goe(form.getDtFrom()));
}
if (form.getDtTo() != null) {
query.where(et1.dt.loe(form.getDtTo()));
}
if (form.getTmFrom() != null) {
query.where(et1.tm.goe(form.getTmFrom()));
}
if (form.getTmTo() != null) {
query.where(et1.tm.loe(form.getTmTo()));
}
if (form.getDtmFromD() != null && form.getDtmFromT() != null) {
query.where(et1.dtm.goe(form.getDtmFromD().toLocalDateTime(form.getDtmFromT())));
}
if (form.getDtmToD() != null && form.getDtmToT() != null) {
query.where(et1.dtm.loe(form.getDtmToD().toLocalDateTime(form.getDtmToT())));
}
return query;
}
};
}